Done.
Download and install getResources from the repository.
First create a chunk called "currentIdx" with the following content:
[[*id:is=`[[+id]]`:then=`[[+idx]]`:else=``]]
Next add the following lines to your template:
<!-- This snippet will return the index number of the current resource.
The first results has an index number of 0
-->
[[getResources?
&parents=`[[*parent]]`
&idx=`0`
&tpl=`currentIdx`
&limit=`999`
&depth=`1`
&showHidden=`1`
&sortby=`menuindex`
&sortdir=`asc`
&toPlaceholder=`currentIdx`
]]
<!-- This will return individual placeholders
for each sibling in the list of results
-->
[[getResources?
&parents=`[[*parent]]`
&idx=`0`
&tpl=`@INLINE <a href="[[~[[+id]]]]">[[+pagetitle]]</a>`
&limit=`999`
&depth=`1`
&showHidden=`1`
&sortby=`menuindex`
&sortdir=`asc`
&toSeparatePlaceholders=`resultno_`
]]
You can grab the results using this syntax:
<!-- The first resource -->
[[+resultno_0]]
<!-- The nth resource -->
[[+resultno_nth]]
<!-- The previous resource -->
[[+resultno_[[+currentIdx:strip:decr]]]]
<!-- The current resource -->
[[+resultno_[[+currentIdx:strip]]]]
!-- The next resource -->
[[+resultno_[[+currentIdx:strip:incr]]]]
<!-- The last resource -->
[[+resultno_[[+total:decr]]]]
Now its only a question of asking politely for the links you need:
<ul>
<!-- Either a link to the resource before the current one OR to the last resource in the list of results -->
[[+currentIdx:strip:is=`0`:then=`
<!-- Last resource -->
<li class="last">[[+resultno_[[+total:decr]]]]</li>
`:else=`
<!-- Previous resource -->
<li class="prev">[[+resultno_[[+currentIdx:strip:decr]]]]</li>
`]]
<!-- The current resource. I don't think you'll need that one -->
<li class="current">[[+resultno_[[+currentIdx:strip]]]]</li>
<!-- Either a link to the next resource OR the first resource in the list of results -->
[[+currentIdx:is=`[[+total:decr]]`:then=`
<!-- First resource -->
<li class="first">[[+resultno_0]]</li>
`:else=`
<!-- Next resource -->
<li class="next">[[+resultno_[[+currentIdx:strip:incr]]]]</li>
`]]
</ul>
Hint: You can freely change the html syntax to fit your needs.
I have tested this code on one of my test accounts and it seems to be working as intended. Try it for yourself and let me know if there are any problems.
As both getResources calls don't use template variables and other heavy-weight stuff, I don't think this solution has any serious performance impact as long as you don't post hundreds of portffolios.
Regards,
pepebe
[ed. note: pepebe last edited this post 10 years, 2 months ago.]