Main Content

Magnolia Community Forums: Get help with Magnolia: Access content-app on page


  • bartoszpiskiewicz
    bartoszpiskiewicz
    Full name: Bartosz Piƛkiewicz
    Posts: 1
    Last post: Jun 8, 2017 10:41:01 AM
    Registered on: Jun 8, 2017
    Access content-app on page
    #1 by bartoszpiskiewicz on Jun 8, 2017 10:41:01 AM

    Hi,

    I've created a content-app by groovy script. I wonder if there's a possibility to access its data directly from page, without creating component. How could I list all items in my content-app on a website?

  • ahietala
    ahietala
    Full name: Antti Hietala
    Posts: 338
    Last post: Jun 8, 2017 11:51:08 AM
    Re: Access content-app on page
    #2 by ahietala on Jun 8, 2017 11:51:08 AM

    Hi Bartek,

    Yes, you can access your content items from a page template script. You don't necessarily need a component.

    Here's how you would get all tours from our demo Tours app (tours workspace) and render their names in a page template.


    [#assign myTours = cmsfn.contentByPath("/magnolia-travels", "tours")]

    <ul>
    [#list cmsfn.children(myTours, "mgnl:content") as child ]
    <li>${child.name!}</li>
    [/#list]
    </ul>


    Docs that may help:
    https://documentation.magnolia-cms.com/display/DOCS/cmsfn
    https://documentation.magnolia-cms.com/display/DOCS/Hello+Magnolia (You can stop after "Creating a page template")

    --Antti

You don't have the permission to post on this thread

Sign in

To login on this forum, you can use your Magnolia Forge, Support or Partner account, or, below, your Google, Yahoo! or OpenID account. If you have trouble logging in, or any other sort of issue, please let us know in the Meta forum, on the user-list, or simply by email at forum-admin at magnolia-cms dot com.

* Required

... or sign in with:

  • icon http://{your-openid-url}
  • icon
  • icon https://me.yahoo.com/