tag:help-archives.hannonhill.com,2010-02-09:/discussions/velocity-formats/14443-moved-format-to-another-region-and-now-failsCascade CMS: Discussion 2016-07-25T20:34:18Ztag:help-archives.hannonhill.com,2010-02-09:Comment/404026912016-07-25T19:29:15Z2016-07-25T19:29:15ZMoved Format to another Region and now fails<div><p>Hi Rick,</p>
<p>By default, the DEFAULT region will return the current page's
Structured Data so that it is readily available to be transformed
by a Format. This data comes in the form:<br></p>
<pre>
<code><system-data-structure>
...page content here...
</system-data-structure></code>
</pre>
which is why your XPath statement in your Format:<br>
<pre>
<code>#set ($navPath = $_XPathTool.selectSingleNode($contentRoot,"/system-data-structure/leftNavBlock/path"))</code>
</pre>
worked in the DEFAULT region.
<p>All other regions will <em>not</em> automatically provide the
page's data to you. Instead, you have to create an Index Block that
basically indexes the current page so that you can get to the data
you're looking to transform. Check out <a href="http://help.hannonhill.com/kb/frequently-asked-questions/create-a-calling-page-index-block">
this article</a> for an example of how to create a 'current page
Index Block'. Once you have this Index Block created, you can do
the following:</p>
<ul>
<li>Click Edit on your Format</li>
<li>In the Preview Options drop down menu, select Block</li>
<li>In the Block Chooser, select your new 'current page' Index
Block</li>
<li>In the Context Page field, select one of the Pages you're
trying to get this to work on</li>
<li>After you select a Context Page, you should see content
rendered in the preview to show you the data available to you</li>
<li>You'll see that the XML now looks like:
<pre>
<code><system-index-block>
...
<system-data-structure>
...
</system-data-structure>
...
</system-index-block></code>
</pre></li>
<li>Since the XML tree structure is different, you can modify your
Format in this interface such to match it up</li>
</ul>
<p>For example, I'm guessing you'll need to change:<br></p>
<pre>
<code>#set ($navPath = $_XPathTool.selectSingleNode($contentRoot,"/system-data-structure/leftNavBlock/path"))</code>
</pre>
to something like:<br>
<pre>
<code>#set ($navPath = $_XPathTool.selectSingleNode($contentRoot,"/system-index-block/calling-page/system-page/system-data-structure/leftNavBlock/path"))</code>
</pre>
<p>It seems like a lot, but it's not bad once you get the hang of
it. Let me know if this helps at all!</p></div>Timtag:help-archives.hannonhill.com,2010-02-09:Comment/404026912016-07-25T19:50:32Z2016-07-25T19:50:33ZMoved Format to another Region and now fails<div><p>Thank you - that is definitely very informative!</p>
<p>Unfortunately it only worked to a point. Everything went exactly
how you said it would, until it got to the XML preview. The XML was
there as expected, but it just sort of stopped.</p>
<p>Whereas the expected path was:
/system-index-block/calling-page/system-page/system-data-structure/leftNavBlock/path</p>
<p>The actual tree went no lower than:
/system-index-block/calling-page/system-page</p>
<p>That level did have some page-level attributes on it, but there
was no system-data-structure to go lower.</p>
<p>(Edit: I replied once but not sure it actually worked. So if
this is a duplicate post, I apologize)</p></div>Ricktag:help-archives.hannonhill.com,2010-02-09:Comment/404026912016-07-25T19:57:10Z2016-07-25T19:57:10ZMoved Format to another Region and now fails<div><blockquote>
<p>That level did have some page-level attributes on it, but there
was no system-data-structure to go lower.</p>
</blockquote>
<p>Gotcha. Edit your Index Block and make sure the following
options are checked:</p>
<ul>
<li>Indexed Asset Content: Regular Content</li>
<li>Page XML: Render page XML inline</li>
</ul>
<p>Let me know if one of those was missing and whether or not you
can see the info now.</p>
<p>Thanks</p></div>Timtag:help-archives.hannonhill.com,2010-02-09:Comment/404026912016-07-25T20:02:46Z2016-07-25T20:02:50ZMoved Format to another Region and now fails<div><p>Yep - I skipped the Page XML part. User Error (surprise!) :)</p>
<p>So now in the preview, I got what I expect to get. OK, what you
told me to expect to get :)</p>
<p>However, I am still getting the following error:</p>
<p>An error occurred: Could not transform with Script format
"DemoFolder/Formats/ICL Left Nav":
org.apache.velocity.exception.MethodInvocationException: Invocation
of method 'selectSingleNode' in class org.jdom.xpath.JaxenXPath
threw exception java.lang.NullPointerException at
velocityTransform-1469476836377[line 8, column 30]</p>
<p>Does that index block get attached to the page someplace? Or is
it only used as a preview item when looking at the format?</p></div>Ricktag:help-archives.hannonhill.com,2010-02-09:Comment/404026912016-07-25T20:20:38Z2016-07-25T20:20:38ZMoved Format to another Region and now fails<div><blockquote>
<p>Does that index block get attached to the page someplace? Or is
it only used as a preview item when looking at the format?</p>
</blockquote>
<p>Yes. If you're getting the error you mentioned when viewing the
Page itself, that makes sense because you haven't attached it yet.
To attach it, you'll want to edit the Configuration for this Page,
then assign your 'current page' Index Block to the same region
where your Format is currently applied.</p>
<p>As a side note, if you go through the preview steps again for
your Format, you'll see that there is a Test Format button. This
runs the transformation against the XML that you see in the
preview, so it's very useful for troubleshooting without having to
apply the Block to the Page first.</p>
<p>I'll wait to hear back and we can go from there.</p>
<p>Thanks</p></div>Timtag:help-archives.hannonhill.com,2010-02-09:Comment/404026912016-07-25T20:29:37Z2016-07-25T20:29:39ZMoved Format to another Region and now fails<div><p>Ugh. Yeah. I should have known that. /facepalm.</p>
<p>Looks like it is working now. Thank you very much!</p></div>Ricktag:help-archives.hannonhill.com,2010-02-09:Comment/404026912016-07-25T20:34:15Z2016-07-25T20:34:15ZMoved Format to another Region and now fails<div><p>Awesome.</p>
<p>You'll basically repeat this process for any other regions
(aside from DEFAULT) where you need to output data from the page
itself. You may also be interested in learning about the <a href="http://www.hannonhill.com/kb/Script-Formats/#locator-tool">Locator
Tool</a> which can eliminate the need for having Index Blocks.</p>
<p>Have a good one, Rick!</p></div>Tim