tag:help-archives.hannonhill.com,2010-02-09:/discussions/velocity-formats/9511-locator-tool-and-serializer-toolCascade CMS: Discussion 2014-03-31T19:20:12Ztag:help-archives.hannonhill.com,2010-02-09:Comment/322981422014-03-27T20:41:32Z2014-03-27T20:41:32ZLocator Tool and Serializer Tool<div><p>Hi,</p>
<p>First let me say that we love the locator tool! It's helping us
cut down our rendering time. :)</p>
<p>That said, I was wondering if it's possible to use the
Serializer Tool on WYSIWYG content pulled with the Locator Tool? I
tried this:</p>
<pre>
<code>#set ( $physical_address = $page.getStructuredDataNode("department-information/physical-address").textValue)
## Using the escape tool sort of works...
$_EscapeTool.xml($physical_address)
## The serializer tool does not work
$_SerializerTool.serialize(physical_address, true)</code>
</pre>
<p>The above outputs:</p>
<pre>
<code><p>Words words words<br/>Even more words</p>
$_SerializerTool.serialize(physical_address, true)</code>
</pre>
<p>The Escape tool shows the mark up from the WYSIWYG (which I
expected) in the output, and the way that I'm trying to use the
serializer tool doesn't do anything at all. Any help is
appreciated. Thanks!</p></div>Ashley Williamstag:help-archives.hannonhill.com,2010-02-09:Comment/322981422014-03-28T13:18:03Z2014-03-28T13:18:03ZLocator Tool and Serializer Tool<div><p>Hi Ashley,</p>
<p>It looks like you are missing the dollar sign before the
<strong>physical_address</strong> variable. When you have a moment,
try the following and let me know how it works out:</p>
<pre>
<code>$_SerializerTool.serialize($physical_address, true)</code>
</pre>
<p>Please let me know if you have any questions.</p>
<p>Thanks!</p></div>Ryan Griffithtag:help-archives.hannonhill.com,2010-02-09:Comment/322981422014-03-31T12:37:43Z2014-03-31T12:37:43ZLocator Tool and Serializer Tool<div><p>After adding the $ to physical address, I still have the same
problem (though I should have noticed that before asking, thanks
for catching that). Now the output is:</p>
<pre>
<code>$_SerializerTool.serialize($physical_address, true)</code>
</pre></div>Ashley Williamstag:help-archives.hannonhill.com,2010-02-09:Comment/322981422014-03-31T15:14:04Z2014-03-31T15:14:04ZLocator Tool and Serializer Tool<div><p>Thank you for following up, Ashley.</p>
<p>Looking over your code snippet again, I noticed you are setting
the <code>$physical_address</code> variable to the node's
<code>textValue</code> property. I suspect the issue is occurring
because the Serializer Tool expects a JDOM Element to serialize,
but you are passing in a String.</p>
<p>When you have a moment, try the following and let me know how it
works out:</p>
<pre>
<code>#set ( $physical_address = $page.getStructuredDataNode("department-information/physical-address"))
$_SerializerTool.serialize($physical_address, true)</code>
</pre>
<p>Please let me know if you have any questions.</p>
<p>Thanks!</p></div>Ryan Griffithtag:help-archives.hannonhill.com,2010-02-09:Comment/322981422014-03-31T15:37:44Z2014-03-31T15:37:44ZLocator Tool and Serializer Tool<div><p>Removing ".textValue" doesn't seem to work either. Here's my
code in its entirety (though I did take out the EscapeTool part
since that no longer works after I removed .textValue):</p>
<pre>
<code>## Get folders
#set ( $folders = $_XPathTool.selectNodes($contentRoot, "//system-folder[descendant::system-page[@current]]") )
#set ( $blank = "" )
$_SortTool.addSortCriterion("count", "", "text", "descending", "upper-first")
$_SortTool.sort($folders)
#foreach ( $folder in $folders )
## Get _info file
#set ( $infoFile = $_XPathTool.selectSingleNode($folder, "system-page[name='_info']") )
#set ( $page = $_.locatePage($infoFile.getChild("path").value, $infoFile.getChild("site").value) )
## Physical address
#set ( $physical_address = $page.getStructuredDataNode("department-information/physical-address"))
#end
#if ( $infoFile )
<p class="title">Contact</p>
## Physical Address
#if (!$_PropertyTool.isNull($physical_address))
$_SerializerTool.serialize($physical_address, true)
#else
${blank}
#end
#else
#end</code>
</pre></div>Ashley Williamstag:help-archives.hannonhill.com,2010-02-09:Comment/322981422014-03-31T15:59:27Z2014-03-31T15:59:27ZLocator Tool and Serializer Tool<div><p>Hi Ashley,</p>
<p>Thank you for providing the entire Format.</p>
<p>It looks like you are displaying the content outside of the
<code>#foreach</code> loop. Perhaps try moving that inside of the
loop to see if that changes the output.</p>
<p>Also, can you confirm the <code>#if</code> statement that
outputs the content is returning true?</p>
<blockquote>
<p>I did take out the EscapeTool part since that no longer works
after I removed .textValue</p>
</blockquote>
<p>Correct, the Escape Tool expects a String, so passing in the
JDOM Element will cause that to break. If you do need to escape the
content, you would want to pass the serialized content into the
Escape Tool. Something like the following:</p>
<pre>
<code>#set ( $physical_address = $_SerializerTool.serialize($physical_address, true) )
$_EscapeTool.xml($physical_address)</code>
</pre>
<p>Please let me know if you have any questions.</p>
<p>Thanks!</p></div>Ryan Griffithtag:help-archives.hannonhill.com,2010-02-09:Comment/322981422014-03-31T16:11:38Z2014-03-31T16:11:38ZLocator Tool and Serializer Tool<div><p>This is what made it work. I have the below set up in the
#foreach loop:</p>
<pre>
<code>#set ( $physical_address = $page.getStructuredDataNode("department-information/physical-address").textValue)
#set ( $physical_address = $_SerializerTool.serialize($physical_address, true) )</code>
</pre>
<p>Then I used ${physical_address} to display it in the #if
statement. Thank you for your help!</p></div>Ashley Williamstag:help-archives.hannonhill.com,2010-02-09:Comment/322981422014-03-31T16:15:47Z2014-03-31T16:15:47ZLocator Tool and Serializer Tool<div><p>Ah, my apologies, Ashley. I didn't take notice of the
<code>getStructuredDataNode</code> part, so you're right in that
<code>textValue</code> should give you the content to
serialize.</p>
<p>I am glad to hear you were about to get things working. I'll go
ahead and close this discussion, but please feel free to comment or
reply to re-open if you have any additional questions.</p>
<p>Have a great day!</p></div>Ryan Griffith