Main Content

Magnolia Community Forums: Get help with Magnolia: How can I get a list of entries in a Content App?

  • pixelnate
    Full name: Nate T
    Posts: 1
    Last post: Dec 14, 2016 11:06:48 PM
    Registered on: Dec 14, 2016
    How can I get a list of entries in a Content App?
    #1 by pixelnate on Dec 14, 2016 11:06:48 PM

    First, I just want to say hello. This is my first post here. The company I work for is moving from SharePoint to Magnolia, and, for the most part, we are very happy with it. We are, however, running into some issues trying to understand some very simple things that are very easy n other platforms.

    For instance, we are trying to get a list of entries in a content app we built to keep track of all of our disclosures. The content app is called 'disclosure', and we have a disclosureAll.yaml file that points to our disclosureAll.ftl file that we want to use to display all of those entries. We created a list that we want to iterate over, but cannot grok the command/function that we need to call on the 'disclosure' content app to make it work. The code is as follows:

    [#list cmsfn.children(content, "disclosure") as child]

    <div class="disclosure">
    [#if child.header?has_content]

    That doesn't throw an error, but it also doesn't display anything. We've tried just about everything on the CMSFN page in the docs, but still no joy.

    Can any of you help us out with the magic spell to call so that we can list out these disclosures?



  • czimmermann
    Full name: Christopher Zimmermann
    Posts: 65
    Last post: Mar 28, 2017 11:27:20 AM
    Re: How can I get a list of entries in a Content App?
    #2 by czimmermann on Dec 22, 2016 9:52:09 AM

    Hi Nate, and welcome!
    The missing link is simply that you you need to first get a contentNode from the contentapp, see cmsfn.contentByPath() for example.
    In a template script - the "content" variable always refers to what is stored in the current component on the page - that is - the things stored by the user via the dialog.

    Here is a script which pulls content from the tours app of the travel demo.

    <div class="contentDemo">

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

    [#list tours as tour ]
    <li>${!} </li>


    Hope this helps.
    We'll take a look at how the documentation can be improved to make this more obvious.

    Cheers, Topher

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