If you want to filter your results as part of your XPath query,
you can always add more criteria using an and
clause: #set ($items = $_XPathTool.selectNodes($contentRoot,
'Class' and node = 'value']]"))
If you're looking to sort your actual returned pages, you can
use the $_SortTool and multiple addSortCriterion()
methods to order the returned pages that meet the criteria in your
Thanks for the quick reply Charlie. When I used the XPath query
you listed above, I wasn't getting anything to display. I thought I
might need to call the system folder, since the folder that is
indexed has several sub folders.
I tried this: #set ($folderPages = $_XPathTool.selectNodes($contentRoot,
= 'Class' and node != 'index']]"))
Any insight on what I need to change? I'd rather filter the
results in the query, than sort the actual returned pages.
In my example code I used the word 'node' because I wasn't 100%
sure what your full criteria was. You'll probably want to replace
the word 'node' with the actual name of the XML element your
testing the value of 'index' to be not equal to.
Hopefully that makes sense.
If you still aren't able to achieve your final result, would you
mind posting a sample of XML data as an attachment so that I can
pull it into a local instance and play around? Also provide a
sample of the desired end result. I may be able to help narrow down
any other issues we are overlooking.
Hmmm. Changed 'node' to 'name' and still no data returned.
I've attached some xml and a small screenshot of what we're
trying to accomplish.
It would also be nice if we could display the folder names as a
header, then list the classes underneath, like so:
Family & Friends CPR (read more link)
Healthcare Provider CPR (read more link)
Yeah so the issue was with the location of the nodes you were
filtering on. Initially you were trying to filter based on the
category in the system-data-structure and
the name of the system-page. Those two
fields are at different levels in the XML data set. So it was just
making sure that the filter matched the proper structure.
As a side note, think about using the Category field as a
Dynamic Metadata field (either custom checkbox, radio, or dropdown
would work best). You would no longer have to include the Page XML
(the system-data-structure), making your block run significantly
faster. I know it's a big transition, but depending on how many
places this block is being used (every page in your site?), you
could save your system a great deal of processing time. That's an
entire page worth of content that is being loaded into the XML data
and not being used every single time the page loads inside of
Cascade Server for every user.
You'd also have to update all the formats to be something
#set ( $folderPages = $_XPathTool.selectNodes($contentRoot, "/system-index-block/system-folder/system-page[name!='index' and dynamic-metadata[name='category' and value='Class']]") )
I'm working on a second course catalog for our employees. Currently
for the general public we use the Category to filter out just the
pages marked as "Class." We use "Internal Events - CMH Employees
Only" for internal trainings, etc. I'd like to use the format and
index block we have above but have it show/output classes and
internal events. I tried this, but it just displays all of the
pages within the folder, regardless of their "Category."