tag:help-archives.hannonhill.com,2010-02-09:/discussions/velocity-formats/14196-from-template-region-to-locateblock-navigationCascade CMS: Discussion 2018-10-18T20:37:55Ztag:help-archives.hannonhill.com,2010-02-09:Comment/398958442016-05-17T14:14:53Z2016-05-17T14:19:15Zfrom template region to locateblock (navigation)<div><p>Hi Nando,</p>
<p>The problems you are trying to solve are really complex. So let
us disentangle them and look at them one by one.</p>
<ol>
<li>
<p>You have to understand the difference between using indexing and
the Locator Tool. With the Locator Tool, you don't have block XML
to work with anymore, at least not yet. This is particularly true
with respect to index blocks, because even if you can locate an
index block, you will have no block XML to work with. The only
choice you have (but see below!) is to start with
<code>$currentPage</code> and look around. That is to say, if you
start with the current page, you have to go through the Cascade
API, get the parent folder, and examine each of its children, one
by one, and determine what to do with them. They are all Cascade
API objects, and there is no more <code>selectNodes</code> or
<code>selectSingleNode</code>, or <code>getChild</code> or
<code>getChildren</code>. Instead, you'll have
<code>getChildren</code> (of a FolderAPIAdapter object),
<code>getStructuredDataNodes</code>,
<code>getStructuredDataNode</code>, and <code>getMetadata</code>.
You will need to tackle the Cascade API directly. It sounds like
you don't feel too comfortable with Velocity. If this is the case,
then don't even start with the Locator Tool because it is harder
than handling block XML.</p>
</li>
<li>
<p>By "all encompassing format", I believe that you are talking
about the format attached to the DEFAULT region (what I call the
default format). A large format can be hard to maintain. You can
abstract out reusable code and put it somewhere else and keep the
default format small. Division of labor. Although my default format
processes all the data nodes, produces the page layout, the
breadcrumbs, and the left navigation, there are only 430 lines in
the format.</p>
</li>
<li>
<p>It is a mistake to think that you can either use
<code>$contentRoot</code>, or the Locator Tool, but not both. In
fact, within the context of the default format, you can have both.
From the index block calling-page, you can have the information of
the parent folder, of all the siblings of the current page, and
even of all the descendants of the siblings, all in the block XML.
But of course you can also use the Locator Tool here. In fact, I
have to use both in my default format to solve the index cache
problem.</p>
</li>
<li>
<p>It is not correct to think that without regions, you cannot have
block-format pairs. I can use an instruction block, containing 1) a
block to be processed, and 2) a script block, containing format
information (the format required to process the block), to replace
a region, attach the instruction block to a block chooser in a
page, and yet the default format does not really process the
instruction block. But again, this requires a thorough
understanding of Velocity before terms like instruction blocks and
script blocks will ever make sense.</p>
</li>
<li>
<p>You definitely need to understand the Velocity code you
attached. But watch out for lines that do not really do anything.
It also seems that you are dealing with a very complicated nav
system, and a lot of crucial information is missing from the
attached XML file. It is definitely possible to build the nav
system, with the availability of both block XML and the Cascade
API. Understanding the format you already have is a start.</p>
</li>
</ol>
<p>You may want to look at my <a href="http://www.upstate.edu/cascade-admin/formats/velocity/course/index.php">
Velocity Tutorial</a> for ideas, for explanations on terms like
instruction blocks, and for the Cascade API documentation.</p>
<p>One more thing. Will you be interested in a series of Google
hangouts, like those I have been doing with web services, and talk
about Velocity?</p>
<p>Wing</p></div>Wing Ming Chantag:help-archives.hannonhill.com,2010-02-09:Comment/398958442016-05-17T14:38:05Z2016-05-17T14:38:05Zfrom template region to locateblock (navigation)<div><p>I've used both indexing and the Locator Tool before, in the same
format and separate - I'm just not familiar with attached format
enough to painlessly convert it to use to Cascade API.</p>
<p>I've attached blocks to pages before used similar formats but I
need to find the nav blocks dynamically so I must use the Locate
Tool.</p>
<p>Your instructions blocks idea is great and I already see where I
can use it but not for this.</p>
<p>I'm going to clean up the current format and remove all the code
not being used and go from there...</p>
<p>Thanks</p></div>Nandotag:help-archives.hannonhill.com,2010-02-09:Comment/398958442016-05-17T14:39:00Z2016-05-17T14:39:00Zfrom template region to locateblock (navigation)<div><p>I'm also going to have to take you up on your Google hangouts
offer one day soon, thanks again.</p></div>Nandotag:help-archives.hannonhill.com,2010-02-09:Comment/398958442016-05-17T15:03:50Z2016-05-17T15:03:50Zfrom template region to locateblock (navigation)<div><p>Please help me understand why you must use the Locator Tool. To
start with, the nav blocks are index blocks, right? If they are
index blocks, and if you have to use the Locator Tool to find them,
then you are stuck, because there are NO methods defined in
IndexBlockAPIAdapter to work with indexed content. Simply put,
there is nothing you can work with, no XML, no methods.</p>
<p>Wing</p></div>Wing Ming Chantag:help-archives.hannonhill.com,2010-02-09:Comment/398958442016-05-17T15:08:21Z2016-05-17T15:08:21Zfrom template region to locateblock (navigation)<div><p>How else would I find the index block if not with the locate
tool? it's not tied to a region or a page... I dont want it tied to
a region and/or page.</p>
<p>I've attached an index block to a page (with a block chooser)
and retrieved the data - I'm thinking along the same route - locate
index block and use cascade api to retrieve data...</p>
<p>if you're free, I can contact you on hangouts directly now -
what is your gmail?</p></div>Nandotag:help-archives.hannonhill.com,2010-02-09:Comment/398958442016-05-17T15:16:22Z2016-05-17T15:16:22Zfrom template region to locateblock (navigation)<div><p>Send me an email to my work place (which can be found at
<a href="http://conference.hannonhill.com/2015/java-jsp-velocity.php">
http://conference.hannonhill.com/2015/java-jsp-velocity.php</a>)
and I can give you my gmail address.</p>
<p>Wing</p></div>Wing Ming Chantag:help-archives.hannonhill.com,2010-02-09:Comment/398958442016-05-20T13:57:43Z2016-05-20T13:57:43Zfrom template region to locateblock (navigation)<div><p>thanks for the 1 on 1s Wing!</p></div>Nando