velocity format help
I am trying to display the following node with the
<
, >
replaced with the
symbols <
, >
so it produces a
working link.
<caption>The new study provides insight into how a critical mitochondrial enzyme, transhydrogenase (TH), works in a process that is key to maintaining healthy cells. <a href='http://www.scripps.edu/news/press/2015/stout_image_enlarge.html'/>(Click for details.)</a></caption>
I have tried a bunch of stuff, but I can't get it to work.
The format gives errors when trying to use caption.text.
Thanks,
Thomas
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 Penny on 07 Jan, 2015 08:31 PM
Can you provide the current velocity that outputs the above content?
I am wondering is < and > are input or if this is what is being transformed. So I think the solution is $_SerializerTool.serialize($caption, false) instead of $caption.value.
If you can send me your original format I am happy to give more feedback. Thanks!
2 Posted by Thomas Edsall on 07 Jan, 2015 09:03 PM
Here is all of the velocity code. Changing true to false did not help. It just added <caption></caption> around the same text. I want the html codes for < and > to be transformed into the actual < and > symbols.
Not sure what you mean by input. In the edit tab of the page <a href… is typed. But in the XML generated from the page these are showing: < and >
< and > are also showing in the actual page in the browser. So the browser is displaying the html code for the link instead of showing the actual link.
The caption line used to be
#antiamp($caption), but I changed it to $_SerializerTool.serialize($caption, true) because I was getting an error. Now I need to change < and > to < and >.
What I sent before was the xml seen on line 113 below, not the output.
[cid:[email blocked]]
---------entire format code-----------------
##Remove ampersands and sanitize the input for XML
#macro (antiamp $text)
#set($text = $text.text.replace("&", "&"))
#set($text = $text.replace("&", "&"))
$text
#end
#set($entry = $_XPathTool.selectSingleNode($contentRoot, '//entry'))
#set($title = $entry.getChild("title"))
#set($body = $entry.getChild("body"))
#set($contacts = $_XPathTool.selectNodes($entry, '//contact/content/system-data-structure/contact'))
#set($aboutBlocks = $_XPathTool.selectNodes($contentRoot, '//entry/about/content'))
<div class="top_right">
<div id="page_heading">
<h1>News Release</h1>
</div>
</div>
<div id="t4_content-a">
<h2>#antiamp($title)</h2>
$_SerializerTool.serialize($body,true)
#if($aboutBlocks != '')
#foreach($about in $aboutBlocks)
$_SerializerTool.serialize($about,true)
#end
#end
<p># # #</p>
<p>
<strong>For information:</strong><br/>
#foreach($contact in $contacts)
#set($email = $contact.getChild("email").text)
#antiamp($contact.getChild("name")) <br/>
#if($contact.getChild("tel").text != '')
Tel: #antiamp($contact.getChild("tel"))<br />
#end
#if($contact.getChild("fax").text != '')
Fax: #antiamp($contact.getChild("fax"))<br/>
#end
#if($contact.getChild("email").text != '')
<a href="mailto:${email}">${email}</a><br/>
#end
#if($contact.getChild("extra").text != '')
#antiamp($contact.getChild("extra"))
#end
<br/>
#end
</p>
</div>
<div id="t4_sidebar2">
#set($images = $_XPathTool.selectNodes($entry, 'Image'))
#foreach($image in $images)
#set($photo = $image.getChild("image"))
#set($path = $photo.getChild("path").text)
#set($hrimage = $image.getChild("hi-res-image"))
#set($hrpath = $hrimage.getChild("path").text)
#set($caption = $image.getChild("caption"))
#if($path != '/')
<div class="side-img-cap">
<a href="${hrpath}">
<img src="${path}" /></a>
<br/>
#if ($caption != '')
<em class="side-caption">$_SerializerTool.serialize($caption, true)</em>
#end
#if (${hrpath} != '' && $hrpath.matches(".*\.(jpg|gif|png|JPG).*"))
<em>(<a href="${hrpath}">High-res image</a>)</em>
#end
</div>
#end
#end
<br/>
<hr/>
<h2>FOR MORE INFORMATION</h2>
#set($infolinks = $_XPathTool.selectNodes($entry, 'more_info'))
#foreach($infolink in $infolinks)
#set($ilurl = $infolink.getChild("link_url"))
#set($iltext = $infolink.getChild("link_text"))
<div class="more-info-link"><a href="$ilurl.text">$iltext.text</a></div>
#end
<hr/>
</div>
3 Posted by Penny on 07 Jan, 2015 09:33 PM
Would this work?
4 Posted by Thomas Edsall on 07 Jan, 2015 09:45 PM
This did not work.
[cid:[email blocked]]
This produces an error
[cid:[email blocked]]
An error occurred while rendering asset preview: Error on line 62: The element type "em" must be terminated by the matching end-tag "undefined</em>".
5 Posted by Penny on 07 Jan, 2015 10:07 PM
Hi THomas,
I think it may be working but the error is because you have a self closing link tag and then a closinglink tag. So you have the following essentially.
<a /></a>
6 Posted by Penny on 07 Jan, 2015 10:10 PM
Hi Thomas,
This worked for me with the content you sent once I took out the self closing part of the a tag.
7 Posted by Thomas Edsall on 07 Jan, 2015 10:19 PM
I removed the self-closing slash and updated the format like you suggested, but it is still outputting the html codes instead of the symbols.
[cid:[email blocked]]
[cid:[email blocked]]
[cid:[email blocked]]
8 Posted by Thomas Edsall on 07 Jan, 2015 11:24 PM
I figured it out.
Removing the self-closing slash got something working that I tried earlier.
Thanks for your help.
-Thomas
Tim closed this discussion on 08 Jan, 2015 02:03 PM.