tag:help-archives.hannonhill.com,2010-02-09:/discussions/velocity-formats/272-dealing-with-empty-nodeCascade CMS: Discussion 2013-08-20T03:30:56Ztag:help-archives.hannonhill.com,2010-02-09:Comment/197856712012-10-18T17:41:40Z2012-10-18T17:41:40ZDealing with empty node<div><p>Hi,</p>
<p>I believe the issue you may be running into is that you are
using Xpath within the <code>getChild()</code> method, which I
don't think is valid.</p>
<p>What I would do is change</p>
<p><code>#set ($url =
$page.getChild("system-data-structure").getChild("content").getChild("url[.
!= '']").value)</code></p>
<p>to</p>
<p><code>#set ($url =
$_EscapeTool.url($page.getChild("system-data-structure").getChild("content").getChild("url).value))</code></p>
<p>This will grab the value entered and escape the string to ensure
it's a valid URL.</p>
<p>Then at the bottom when you are checking for the existence of a
URL, use something like the following:</p>
<pre>
<code>#if ($url.trim() != "")
<a href="${url}">${employer}</a>
#else
${employer}
#end</code>
</pre>
<p>Please let me know if that does the trick or if you have any
questions.</p>
<p>Thanks</p></div>Ryan Griffithtag:help-archives.hannonhill.com,2010-02-09:Comment/197856712012-10-18T17:51:51Z2012-10-18T17:51:51ZDealing with empty node<div><p>Thanks. that did the trick. Can you give me a quick and dirty
explanation of the .trim function?</p></div>steelejtag:help-archives.hannonhill.com,2010-02-09:Comment/197856712012-10-18T18:01:52Z2012-10-18T18:01:52ZDealing with empty node<div><p>Glad to hear that did the trick.</p>
<blockquote>
<p>Can you give me a quick and dirty explanation of the .trim
function?</p>
</blockquote>
<p>The <code>String.trim()</code> method basically removes any
leading and trailing whitespace from the string. It's not required;
however, if the user enters a space and nothing else, the string
would technically not be blank so you would be outputting a broken
link. The trim would take care of that for you.</p></div>Ryan Griffith