tag:help-archives.hannonhill.com,2010-02-09:/discussions/velocity-formats/9429-locator-tool-getchild-of-getchildCascade CMS: Discussion 2014-03-27T14:09:10Ztag:help-archives.hannonhill.com,2010-02-09:Comment/321493662014-03-19T18:42:51Z2014-03-19T18:42:51ZLocator Tool - getChild of getChild?<div><p>Hi,</p>
<p>I was able to successfully traverse 3 levels in my local Cascade
Server 7.10 instance, so this should definitely be possible.</p>
<p>When you have a moment, please provide the XML of the page's
Data Definition so I can take a look at how the structured data
looks.</p>
<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/321493662014-03-25T17:52:24Z2014-03-25T17:52:24ZLocator Tool - getChild of getChild?<div><p>Hi Ryan,</p>
<p>Thanks for the reply. I've attached an XML document. I'm trying
to access the data on say, line 65. How would I do that using the
Locator Tool?</p>
<p>Thanks</p></div>johjacbtag:help-archives.hannonhill.com,2010-02-09:Comment/321493662014-03-25T20:20:14Z2014-03-25T20:20:14ZLocator Tool - getChild of getChild?<div><p>Hi,</p>
<p>Thank you for providing the XML sample.</p>
<p>Looking over your XML, it appears you are attempting to access
the contents coming from a Block chooser. The
<code>getChild()</code> method will not work with asset choosers,
only text-based fields. You would need to use the asset type's API
(in this case a Block) to access the contents within.</p>
<p>I will make a note to look into this a bit more tomorrow morning
and try to get back to you with some example code to get you
started.</p>
<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/321493662014-03-27T13:03:56Z2014-03-27T13:03:56ZLocator Tool - getChild of getChild?<div><p>Hi,</p>
<p>My apologies for not responding sooner.</p>
<p>Using the sample XML you provided, here is a snippet that would
allow you to traverse into the <code>form-block</code> chooser's
content to access the <code>formhash</code> field:</p>
<pre>
<code>#set ( $page = $_.locatePage($currentPagePath, $currentPageSiteName))
#set ( $formblock = $page.getStructuredDataNode("form-block"))
#set ( $formhash = $formblock.asset.getStructuredDataNode("formhash") )
$formhash.textValue</code>
</pre>
<p>So, I believe what you'll want to do while you're traversing is
to either check if <code>getChildren</code> is null after calling
<code>getStructuredDataNode()</code>, or check if
<code>asset</code> is null, to see if you are dealing with an asset
or a group/text field. The following would be an example of
checking if <code>asset</code> is not null:</p>
<pre>
<code>#if ($formblock.asset)
... code for an asset here ...
#else
... code for a structured data node here ...
#end</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/321493662014-03-27T13:38:42Z2014-03-27T13:38:42ZLocator Tool - getChild of getChild?<div><p>Thanks for the reply.</p>
<p>I was missing the <code>.asset</code> bit in getting the block
contents via <code>.getStructuredDataNode</code>.</p>
<p>Thanks for your assistance.</p></div>johjacbtag:help-archives.hannonhill.com,2010-02-09:Comment/321493662014-03-27T14:09:08Z2014-03-27T14:09:08ZLocator Tool - getChild of getChild?<div><p>Not a problem at all, when I was testing originally I had done
the same exact thing.</p>
<p>I'm going to go ahead and close this discussion, 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