tag:help-archives.hannonhill.com,2010-02-09:/discussions/how-do-i/543-use-of-velocityCascade CMS: Discussion 2018-10-18T20:36:23Ztag:help-archives.hannonhill.com,2010-02-09:Comment/105864162011-10-12T22:03:30Z2011-10-12T22:03:31ZUse of Velocity<div><p>Does anyone have an idea about my question!</p></div>Nishant Limbachiyatag:help-archives.hannonhill.com,2010-02-09:Comment/105864162011-10-12T22:21:13Z2011-10-12T22:21:13ZUse of Velocity<div><p>I posted my question earlier yesterday evening and there were no
replies and I posted this comment couple minutes back as a reply to
my question. But now the original question disappeared! Should I
post my question again?</p></div>Nishant Limbachiyatag:help-archives.hannonhill.com,2010-02-09:Comment/105864162011-10-13T12:34:45Z2011-10-13T12:34:45ZUse of Velocity<div><p>Nishant, I suggest you check out the initial Velocity Webinar
here: <a href=
"http://www.hannonhill.com/products/demos/cascade-velocity-webinar-video.html">
http://www.hannonhill.com/products/demos/cascade-velocity-webinar-v...</a>
and also check the Velocity Resources in the KB - <a href=
"http://www.hannonhill.com/kb/Script-Formats/#technical">http://www.hannonhill.com/kb/Script-Formats/#technical</a></p>
<p>Regards,<br>
Alvin</p></div>chaoajtag:help-archives.hannonhill.com,2010-02-09:Comment/105864162011-10-13T13:35:49Z2011-10-13T13:35:49ZUse of Velocity<div><p>I looked through the logs. I do not see your original post. If
you repost your original question, I'd be glad to comment.</p></div>Charlie Holdertag:help-archives.hannonhill.com,2010-02-09:Comment/105864162011-10-13T17:40:25Z2011-10-13T17:40:28ZUse of Velocity<div><p>@Alvin Thanks for pointing me to those resources. I have already
gone through those. It was about a proof of concept I was working
on and was wondering if that could be achieved using Velocity or
not.</p>
<p>@Charlie:</p>
<h2>I posted my original question on Tuesday, Oct 11th between
5-6pm Pacific time. But anyways, I will re-post it.</h2>
<p>Let's consider my site is structured as below in cascade
server</p>
<pre>
<code> nishantSite
|--- index.html
|--- awaynav.html
|--- tools
|--- index.html
|--- services
|--- index.html
|--- awaynav.html</code>
</pre>
<p>I want to include the awaynav.html file in the away navigation
section of each index.html file that exists at the same level. If
awaynav.html file does not exists at the same level as the
index.html file, then it should include the awaynav.html file from
its parent folder. So to make it more clearer, from the above
example the away navigation for each index.html file should
include:</p>
<ol>
<li>nishantSite/index.html includes: nishantSite/awaynav.html</li>
<li>nishantSite/tools/index.html includes:
nishantSite/awaynav.html</li>
<li>nishatSite/services/index.html includes:
nishantSite/services/awaynav.html</li>
</ol>
<p>I was wondering if this is possible by using Velocity or not! If
I can get the site structure through the XML then I can use the
_XPathTool and some conditionals to make it work!</p>
<p>Just wanted to get some insight from the experts here. :)</p>
<p>Thank you guys, I appreciate your help.</p>
<p>-Nishant</p></div>Nishant Limbachiyatag:help-archives.hannonhill.com,2010-02-09:Comment/105864162011-10-13T18:48:49Z2011-10-13T18:48:49ZUse of Velocity<div><p>This is possible. We have helped create this functionality on a
number of occasions.</p>
<p>I would suggest changing the type of asset you are using for
including your navigation though. I would suggest using a
structured data block or simply an HTML/XML block as the asset
instead of a page. This will SIGNIFICANTLY cut down on the amount
of data that is requested and rendered for creating this
functionality. (If you rendering behavior is for pages, you'll be
including all the pages throughout the folder structure when you
are really just wanting one page. So switching to a block will
allow you to request less data and filter it as needed.)</p>
<p>I can describe, hopefully, what I would do to create this
functionality:</p>
<ol>
<li>
<p>Create a Block (either HTML or XML or Structured) to contain
your navigations. Create as many as you need and place them in the
desired folders. I would continue to use the same name for each
just as you have above.</p>
</li>
<li>
<p>Create an Index Block of "Folder Type" that uses the "Start at
the current page with folder hierarchy, and also include siblings"
rendering behavior -- maybe call it "nav-search" or something.</p>
<p>Do not select an "Index Folder". Check only "Blocks" for the
"Indexed Asset Types" choice.</p>
<p>Make sure you select "Render XHTML/Data Definition block, XML
block, and Text block XML inline" for the "Block XML" section.</p>
<p>Check "Regular Content" and "User Metadata" for the "Indexed
Asset Content" choice.</p>
<p>This block will be applied to a region on one or more pages and
search the relative directory of your current location as well as
each directory up the folder hierarchy for any Block Assets (your
wanted navigational include).</p>
</li>
<li>
<p>Write a Format (easier said than done) to process through that
data. You will have all of the information you'll need to know
which Block data you should output into the Page.</p>
</li>
</ol>
<p>Here are some example chunks of Velocity code that should help
you get over the harder humps:</p>
<p>To select all of the Block Assets:</p>
<pre>
<code>#set ( $navBlocks = $_XPathTool.selectNodes($contentRoot, "//system-folder[descendants::system-page[@current]]/system-block[name='YOUR_BLOCK_NAME']") )</code>
</pre>
<p>You will want just one of the those Blocks, the one that is in
your current folder. But if there isn't one there, you'll want the
Block at another level up. The best way to handle this is to sort
the Blocks by the number of ancestors it has and then take the
first one:</p>
<pre>
<code>$_SortTool.addSortCriterion("count(ancestors::system-folder)","","number","descending","")
$_SortTool.sort($navBlocks)</code>
</pre>
<p>This list may have more than one block even though it's sorted
(it may even have none). So use this logic to select just the first
one when there are Blocks to select:</p>
<pre>
<code>#if ( $navBlocks.size() > 0 )
#set ( $block = $navBlocks.get(0) )
#end</code>
</pre>
<p>That is going to return a reference to the
<code><system-block></code> XML element itself. To pull the
actual HTML out for inserting into your region, you'll have two
different scenarios to consider depending on what kind of Block you
chose to store your navigation information in.</p>
<p>If you used HTML/XML:</p>
<pre>
<code><system-block>
<name/>
<block-xhtml/>
</system-block></code>
</pre>
<p>If you used Structured/Data Definition:</p>
<pre>
<code><system-block>
<name/>
<system-data-structure>
<your-identifier1/>
<your-identifier2/>
<your-identifier3/>
</system-data-structure>
</system-block></code>
</pre>
<p>That is a pretty comprehensive explanation about how you'd go
about putting all those pieces together. "Teach a man to fish" kind
of idea to get you going and I'd be glad you help you work through
any code you put together with these ideas.</p></div>Charlie Holdertag:help-archives.hannonhill.com,2010-02-09:Comment/105864162011-10-13T19:30:48Z2011-10-13T19:30:48ZUse of Velocity<div><p>While not a velocity specific answer perhaps the root solution
presented in <a href=
"https://github.com/hannonhill/Cascade-Server-XSLT/tree/master/Rules-Engine">
https://github.com/hannonhill/Cascade-Server-XSLT/tree/master/Rules...</a>
might be what you are looking for.</p>
<p>It allows assets to have rules about where they should be
used.</p>
<p>Until Hannon Hill allows indexing by Structured Data Blocks of a
particular data definition you could modify it by setting up a
content type for awaynav and use a content type index block to
group all the potential attachments without indexing other content.
Then use the same most specific match rule pattern that is used in
the example to pull the correct awaynav from the index to work
with.</p></div>Jason Allertag:help-archives.hannonhill.com,2010-02-09:Comment/105864162011-10-13T19:45:54Z2011-10-13T19:45:54ZUse of Velocity<div><p>I agree, more options for filtering on Index Blocks and Content
Type Indexes would be great.</p>
<p>Workaround to not being able to index certain Data Definitions:
Use the <code>@definition-path</code> attribute that is attached to
each <code><system-data-structure></code> node?</p></div>Charlie Holdertag:help-archives.hannonhill.com,2010-02-09:Comment/105864162011-10-13T20:39:22Z2011-10-13T20:39:24ZUse of Velocity<div><p>@Jason; @Charlie Thank you guys for giving me your opinions
about it. I am an absolute beginner with Cascade Server and I need
to learn about how to approach a problem more efficiently, whether
to make use of Index blocks or Pages, and more.</p>
<p>For sure I have a lot to process from this discussion and I will
take some time to put this into practice. I would like to get done
with this proof of concept and then post the solution here to help
the community and may be some people have comments on my solution.
For that reason I am not sure whether this discussion can be closed
now or not! Either way, I assure to get back once I am done.</p>
<p>Thank you,<br>
Nishant</p></div>Nishant