Dealing with empty node
In the attached page, I want to display items for Related Documents at the end only when values are entered. I tried #if ($docs.size() > "0") but can't get it to work. If it were working, I don't think it would be the right choice for the way I have this set up as the $docs.size() comes up as 1 when there is no entry.
- script.txt 3.3 KB
- page.xml 6.5 KB
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 steelej on 04 Apr, 2014 06:02 PM
This is not urgent. I would be curious as to the proper way to do this. I thought on it a while and achieved what I wanted by checking the first item under docs for text (which all items would have to have). I used that for my conditional: #if ($dochk.trim() != "")
It works.
2 Posted by Ryan Griffith on 04 Apr, 2014 06:49 PM
Hi Jim,
Have you tried using
#if ($docs.size() > 0)
by chance? Note that thesize()
method returns an integer and not a string.I noticed that the doc items are composed of two asset choosers. You could try using the XPath Tool to filter out items that have a value or a chosen asset and then check for the size of the filtered items. For example:
Please let me know if you have any questions.
Thanks!
3 Posted by Ryan Griffith on 08 Apr, 2014 05:53 PM
Hi Jim,
Just wanted to follow up to see if you had a chance to view my recent comment. Were you able to get your Velocity code working?
Please let us know if you have any questions.
Thanks.
steelej closed this discussion on 09 Apr, 2014 01:12 PM.