Locator Tool - Query API limit query to folder.

kendjone's Avatar

kendjone

30 Jun, 2015 09:25 PM

I want to get all child pages with a particular content type in a folder.

I would assume there would be something like?

#foreach($x in $currentPage.parentFolder.children)
    #if($x.contentType == "site:/mysite/Story")
        <a href="$x.path">
            <article class="list--item">
                <h1>$!x.metadata.title</h1>
                <p>$!x.metadata.description</p>
            </article>
        </a>
    #end
#end

I know you use filter by content type using the Query API:

#set($query = $_.query()) 
#set($query = $query.byContentType("site:/mysite/Story").publishableOnly(true).indexableOnly(true))
#set($pages = $query.execute())
#foreach($x in $pages)
    <a href="$x.path">
        <article class="list--item">
            <h1>$!x.metadata.title</h1>
            <p>$!x.metadata.description</p>
        </article>
    </a>
#end
Is there a way to restrict $_.query() to a folder or location?
i.e.: $query.searchLocation("site:/mysite/folder")

Or a way to inspect assets to determine content type?
i.e: $x.contentType = "site:/mysite/Story"

  1. 1 Posted by Ryan Griffith on 01 Jul, 2015 01:10 PM

    Ryan Griffith's Avatar

    Hi,

    Currently, there is no way to filter the results of the Query Tool by folder. We do have a related suggestion for this on our Idea Exchange. I highly recommend voting this up if you would like the feature to be considered for a future release of Cascade.

    Also, the Page results from the Locator and Query tools will not provide you with the Content Type, only the Data Definition path..

    I think you are on the right track though, where your best bet would be to use the Query tool to obtain all pages for a specific Content Type and while you are looping over the results, check the page's parent folder path to see if it is in the folder you want.

    Please let me know if you have any questions.

    Thanks!

  2. Tim closed this discussion on 17 Jul, 2015 02:33 PM.

Discussions are closed to public comments.
If you need help with Cascade CMS please start a new discussion.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

 

26 Aug, 2016 01:19 PM
25 Aug, 2016 03:02 PM
25 Aug, 2016 12:50 PM
24 Aug, 2016 08:43 PM
24 Aug, 2016 07:20 PM
21 Aug, 2016 01:20 PM