Help w/ For Each
IS there a way to have a for each that looks through an index block of blocks and only shows ones that have a field marked a certain way? I am making a site index that has each listing in its own block with one of the fields a letter chooser to help organize out by the letter.
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
1 Posted by Ryan Griffith on 04 Apr, 2014 06:35 PM
Hi Graham,
There are two ways you could go about doing this:
#if
statement to check the value of your field, and if the condition is true do some code or output somethingPlease let me know if you have any questions.
Thanks!
2 Posted by Graham Lewis on 04 Apr, 2014 06:37 PM
Thanks! I was thinking the #if - how would you do the tool filter for a field?
Graham Lewis
Webmaster
Jacksonville State University
256.782.5331
www.jsu.edu
3 Posted by Ryan Griffith on 04 Apr, 2014 06:43 PM
Not a problem at all. You would use the
XPathTool.selectNodes()
function in conjunction with an XPath expression that checks the value of the field you want.If you could attach some sample XML from the Index Block and what field and value you want to filter by, I would be happy to help out with the XPath expression.
Please let me know if you have any questions.
Thanks!
4 Posted by Graham Lewis on 04 Apr, 2014 06:45 PM
Sure - here it is.
Graham Lewis
Webmaster
Jacksonville State University
256.782.5331
www.jsu.edu
5 Posted by Ryan Griffith on 04 Apr, 2014 06:54 PM
Thank you for providing the XML, Graham. So let's say you want to filter system-blocks by the letter a:
Or, let's say you want the letter to be dynamic based on a field on your page called letter:
Please let me know if you have any questions.
Thanks!
6 Posted by Graham Lewis on 04 Apr, 2014 06:57 PM
Ah - that makes sense. That's gonna be handy! Thanks
Graham Lewis
Webmaster
Jacksonville State University
256.782.5331
www.jsu.edu
7 Posted by Ryan Griffith on 04 Apr, 2014 07:13 PM
Not a problem at all, Graham. I am glad to hear the snippets helped out.
I'm going to go ahead and close this discussion, please feel free to comment or reply to re-open if you have any additional questions.
Have a great day!
Ryan Griffith closed this discussion on 04 Apr, 2014 07:13 PM.