tag:help-archives.hannonhill.com,2010-02-09:/discussions/velocity-formats/11478-block-chooser-in-data-definition-vs-outputsCascade CMS: Discussion 2015-02-10T21:32:35Ztag:help-archives.hannonhill.com,2010-02-09:Comment/360006232015-02-09T20:29:22Z2015-02-09T20:29:22Zblock chooser in data definition vs outputs<div><p>Hi Lauren,</p>
<p>In order to pull in the block's content, you will need to tweak
the XPath used within the first line of your Format to read into
the block chooser's content element. Something like the
following:</p>
<pre>
<code>#set ($data = $_XPathTool.selectSingleNode($contentRoot,"/system-data-structure/BLOCK_CHOOSER/content"))</code>
</pre>
<p>Where <code>BLOCK_CHOOSER</code> would be the identifier you
used for the chooser field.</p>
<p>Note: you will also need to ensure you specify a <strong>Render
Content Depth</strong> for the chooser field itself to ensure the
Format has access to the block's content. This can be accomplished
by editing the Data Definition, edit the block chooser field, and
fill in a value for <strong>Render Content Depth</strong> under the
Advanced options. I generally use a value of 4-5.</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/360006232015-02-09T21:51:39Z2015-02-09T21:51:39Zblock chooser in data definition vs outputs<div><p>Ryan,</p>
<p>I changed the $data variable to the following:</p>
<pre>
<code>
#set ($data = $_XPathTool.selectSingleNode($contentRoot,"/system-data-structure/block-content/content"))</code>
</pre>
<p>And here is the xml from the data definition</p>
<pre>
<code>
<system-data-structure>
<asset type="block" identifier="block-content" label="Content Block" render-content-depth="5"/>
</system-data-structure></code>
</pre>
<p>The content render depth is set to 5, but I’m still not
seeing the content, just the velocity code -
$_EscapeTool.xml($title.value)</p>
<p>I also tried selectNodes, without luck. What am I missing?</p>
<p>Thanks,</p>
<p>Lauren</p></div>lauren.frasertag:help-archives.hannonhill.com,2010-02-09:Comment/360006232015-02-10T20:36:08Z2015-02-10T20:36:08Zblock chooser in data definition vs outputs<div><p>Hi Lauren,</p>
<p>My apologies, I wasn't sure if you wanted the chosen block's
Title metadata field or an actual field within the block's
structured data (ie data definition). If you are attempting to grad
a title field, try adjusting the snippet I provided to the
following:</p>
<pre>
<code>#set ($data = $_XPathTool.selectSingleNode($contentRoot,"/system-data-structure/block-chooser/content/system-data-structure"))</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/360006232015-02-10T21:01:40Z2015-02-10T21:01:40Zblock chooser in data definition vs outputs<div><p>We’re actually trying to grab several fields from the data
definition.</p>
<p>I tried the code you sent as well as what’s below (I
wasn’t sure if I need to replace block-chooser with the name
of the block from the data definition).</p>
<p>I couldn’t get it to with either one.</p>
<p>#set ($data =
$_XPathTool.selectSingleNode($contentRoot,"/system-data-structure/block-content/content/system-data-structure"))</p></div>lauren.frasertag:help-archives.hannonhill.com,2010-02-09:Comment/360006232015-02-10T21:14:42Z2015-02-10T21:14:42Zblock chooser in data definition vs outputs<div><p>Hm. Do you have a <a href=
"http://help.hannonhill.com/kb/frequently-asked-questions/create-a-calling-page-index-block">
calling page Index Block</a> applied to this page's region as well?
If so, you most likely need to tweak the XPath a bit more to grab
that chooser.</p>
<p>When you have a moment, try the following:</p>
<pre>
<code>#set ($data = $_XPathTool.selectSingleNode($contentRoot,"calling-page/system-page/system-data-structure/block-content/content/system-data-structure"))</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/360006232015-02-10T21:24:53Z2015-02-10T21:24:53Zblock chooser in data definition vs outputs<div><p>Ryan,</p>
<p>Thanks that did the trick.</p>
<p>Lauren</p></div>lauren.frasertag:help-archives.hannonhill.com,2010-02-09:Comment/360006232015-02-10T21:32:34Z2015-02-10T21:32:34Zblock chooser in data definition vs outputs<div><p>Not a problem at all, Lauren. I am glad to hear the latest code
snippet did the trick.</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