tag:help-archives.hannonhill.com,2010-02-09:/discussions/velocity-formats/14070-velocity-nextpreviousCascade CMS: Discussion 2018-10-18T20:37:53Ztag:help-archives.hannonhill.com,2010-02-09:Comment/396952102016-04-21T13:30:26Z2016-04-21T13:30:26ZVELOCITY NEXT/PREVIOUS<div><p>Hi Bradley,</p>
<p>The Format provided in the other discussion was meant to be used
for a Content Type Index Block, where the structure is:</p>
<ul>
<li>system-index-block
<ul>
<li>system-page</li>
<li>...</li>
<li>system-page</li>
</ul>
</li>
</ul>
<p>In your case, you are using a Folder Index Block, so the XPath
at the top of the Format will need to be adjusted. Specifically,
<code>system-index-block/system-page[@current]</code> does not
exist because the current page is nested under the
<strong>/opportunity/statpack</strong> folder. Additionally, using
<code>system-index-block/system-page[not(@current)]</code> will
only give you non-current pages at the top level (i.e. base
folder).</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/396952102016-04-21T19:54:23Z2016-04-21T19:54:23ZVELOCITY NEXT/PREVIOUS<div><p>Ryan,</p>
<p>Thanks for the feedback. Here is what I have come up with using
the same xml minus calling page data. I took that out because I
realized I could just check for current attribute w/o the calling
page data.</p>
<p>Included is the velocity and the output. For some reason the
next & previous links aren’t populating off the .get().
But all other data is. Any help would be appreciated</p>
<p>VELOCITY<br>
#set($getPages = $_XPathTool.selectNodes($contentRoot,
'//system-page')) #set($counter=0) #set ( $articlesize =
$getPages.size() )</p>
<ul>
<li><br>
#foreach($page in $getPages) #set ($pageLink =
$page.getChild("link").value) #if($page.getAttribute("current"))
#set ($currentLink = $page.getChild("link").value) #set ($counter =
$foreach.index) #set ($previous = $counter - 1) #set ($next =
$counter + 1) #end
<pre>
<code>#if($currentLink == $pageLink)
#set ($prevPage = $page.get($previous).getChild("link").value)
#set ($nextPage = $page.get($next).getChild("link").value)
#set ($counter = $foreach.index)
#end</code>
</pre>
<p>#end</p>
</li>
<li>SIZE: $articlesize | NEXT: $next | CURRENT: $counter |
PREVIOUS: $previous | CURPG: $currentLink | PREVPG: $prevPage |
NEXTPG $nextPage</li>
<li><br></li>
</ul>
<p>OUTPUT<br></p>
<ul>
<li><br></li>
<li>SIZE: 8 | NEXT: 4 | CURRENT: 3 | PREVIOUS: 2 | CURPG: <a>site://BLIMPIE-FRANCHISING/opportunity/statpack/index</a>
| PREVPG: $prevPage | NEXTPG $nextPage</li>
</ul></div>bwmyerstag:help-archives.hannonhill.com,2010-02-09:Comment/396952102016-04-21T20:16:08Z2016-04-21T20:16:08ZVELOCITY NEXT/PREVIOUS<div><p>Hi Bradley,</p>
<p>It looks like you are attempting to use <code>get()</code> on
the page within the loop, not the entire array of pages. When you
have a moment adjust your format as follows:</p>
<pre>
<code>#if($currentLink == $pageLink)
#set ($prevPage = $getPages.get($previous).getChild("link").value)
#set ($nextPage = $getPages.get($next).getChild("link").value)
#set ($counter = $foreach.index)
#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/396952102016-04-21T21:31:15Z2016-04-21T21:37:36ZVELOCITY NEXT/PREVIOUS<div><p>Thanks Ryan. Looks good. Here is the final code in case anyone
else comes along with the same issue:</p>
<pre>
<code>#set($getPages = $_XPathTool.selectNodes($contentRoot, '//system-page'))
#set($counter=0)
#set ( $articlesize = $getPages.size() )
<ul>
#foreach($page in $getPages)
#set ($pageLink = $page.getChild("link").value)
##<li>$pageLink</li>
#if($page.getAttribute("current"))
#set ($currentLink = $page.getChild("link").value)
#set ($counter = $foreach.index)
#set ($previous = $counter - 1)
#set ($next = $counter + 1)
#end
#if($currentLink == $pageLink)
#if($previous > -1)
#set ($prevPage = $getPages.get($previous).getChild("link").value)
<li><a href="${prevPage}" title="">« PREVIOUS</a></li>
#else
#set ($prevPage = false)
#end
#if($next < $articlesize)
#set ($nextPage = $getPages.get($next).getChild("link").value)
<li><a href="${nextPage}" title="">NEXT »</a></li>
#else
#set($nextPage = false)
#end
#end
#end
##<li>SIZE: $articlesize | NEXT: $next | CURRENT: $counter | PREVIOUS: $previous | CURPG: $currentLink | PREVPG: $prevPage | NEXTPG $nextPage</li>
</ul></code>
</pre></div>bwmyers