VELOCITY NEXT/PREVIOUS
Hello. I found another post that sort of does what I want. It is slightly different and I can't seem to get it to work.
Here is the post | http://help.hannonhill.com/discussions/velocity-formats/10642-is-us...
Attached is xml and velocity. Not sure what is going on. Doesn't seem to be pulling the any data in. Any help would be appreciated. Thanks!
- playground.vm 1.19 KB
- playground.xml 8.37 KB
Discussions are closed to public comments.
If you need help with Cascade CMS please
start a new discussion.
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
1 Posted by Ryan Griffith on 21 Apr, 2016 01:30 PM
Hi Bradley,
The Format provided in the other discussion was meant to be used for a Content Type Index Block, where the structure is:
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,
system-index-block/system-page[@current]
does not exist because the current page is nested under the /opportunity/statpack folder. Additionally, usingsystem-index-block/system-page[not(@current)]
will only give you non-current pages at the top level (i.e. base folder).Please let me know if you have any questions.
Thanks!
2 Posted by bwmyers on 21 Apr, 2016 07:54 PM
Ryan,
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.
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
VELOCITY
#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)
#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)
#set ($prevPage = $page.get($previous).getChild("link").value)
#set ($nextPage = $page.get($next).getChild("link").value)
#set ($counter = $foreach.index)
#end
#end
<li>SIZE: $articlesize | NEXT: $next | CURRENT: $counter | PREVIOUS: $previous | CURPG: $currentLink | PREVPG: $prevPage | NEXTPG $nextPage</li>
</ul>
OUTPUT
<ul>
<li>SIZE: 8 | NEXT: 4 | CURRENT: 3 | PREVIOUS: 2 | CURPG: site://BLIMPIE-FRANCHISING/opportunity/statpack/index | PREVPG: $prevPage | NEXTPG $nextPage</li>
</ul>
3 Posted by Ryan Griffith on 21 Apr, 2016 08:16 PM
Hi Bradley,
It looks like you are attempting to use
get()
on the page within the loop, not the entire array of pages. When you have a moment adjust your format as follows:Please let me know if you have any questions.
Thanks!
4 Posted by bwmyers on 21 Apr, 2016 09:31 PM
Thanks Ryan. Looks good. Here is the final code in case anyone else comes along with the same issue:
bwmyers closed this discussion on 21 Apr, 2016 09:31 PM.