velocity formats on a text block
I am attempting to apply this format:
[code]
##test to see if page has data
#if (!$_PropertyTool.isNull($contentRoot))
##retrieve the full page data
#set ( $h1 = $_XPathTool.selectSingleNode($contentRoot,"/block-xhtml") )
#if ($h1.value != '')
<div class="page-header">
<h1 class="container">$_EscapeTool.xml($h1.value)</h1>
</div>
#end
#end
[/code]
to a text block:
[code]
<block-xhtml>About Us</block-xhtml>
[/code]
When I click "test format" I get what I expect:
[code]
<div class="page-header">
<h1 class="container">About Us</h1>
</div>
[/code]
When I use the same format on a block assigned via a configuration set I get:
[code]
<div class="page-header">
<h1 class="container">$_EscapeTool.xml($h1.value)</h1>
</div>
[/code]
as if the h1 value is not defined.
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
Support Staff 1 Posted by Tim on 18 Mar, 2016 03:16 PM
Hi Kris,
Thanks for including all of those details. To clarify, is it safe for me to say that your Text Block really only contains the text 'About Us'? You mentioned that it contains:
but I'm assuming you're going by what you're seeing in the Test Format interface when you select that Block.If that is indeed the case, the reason for those added
In the context of a Page, however, the<block-xhtml>
tags is so that the content is valid XML (because without them, there wouldn't be a root element). This makes your Format work in the Test Format interface because you're looking for the child element<block-xhtml>
from the contentRoot here:<block-xhtml>
element doesn't exist because it is assumed that the section of the Page you are placing it into is already well formed. So, if you're simply trying to output the contents of whatever is in your Text Block, try changing this line to something like:and let me know if that helps.
Thanks!
2 Posted by Kris on 18 Mar, 2016 03:29 PM
Thanks Tim, that was indeed what the issue was.
Support Staff 3 Posted by Tim on 18 Mar, 2016 03:32 PM
Cool! Thanks for the update, Kris! Glad that helped.
Have a good one.
Tim closed this discussion on 18 Mar, 2016 03:32 PM.