Menu with forward/back and counter

For discussion and questions related to CMS Specific templates and stylesheets (CSS), and themes. or layout issues. This is not a place for generic "I don't know CSS issues"
Post Reply
thomsonson
Forum Members
Forum Members
Posts: 39
Joined: Wed Aug 24, 2011 9:47 am

Menu with forward/back and counter

Post by thomsonson »

Hello all,

I am trying to work out the best way to implement a simple paginating menu in cmsms (back / forward links and a n of n counter). I know that the news and guestbook modules have this function built in, but for various reasons, I want to be able to do it with actual pages.

Ideally, this would be set up as the submenu, and it would be possible to cycle through all the child pages of a certain parent with the back & next links, and have the counter keep track of position.

I can't find a cms menu template which does this, and I have tried to put a solution together using the content_dump tag, but to no avail.. My strengths are rather more in design than coding, so any help or tips with this would be hugely appreciated :)
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

Re: Menu with forward/back and counter

Post by Dr.CSS »

Maybe an image of what you want to do would help...
mcDavid
Power Poster
Power Poster
Posts: 377
Joined: Tue Mar 31, 2009 8:45 pm

Re: Menu with forward/back and counter

Post by mcDavid »

You can use {cms selflink} for that!
(optional) dir start/next/prev/up (previous) - Links to the default start page or the next or previous page, or the parent page (up). If this is used page should not be set.
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: Menu with forward/back and counter

Post by calguy1000 »

it can also be done as a simple menu manager template...

you would just have to:
a: get the total count of the items (simple enough)
b: loop through the nodelist once to find the current node's index
{$node->current} indicates that IIRC.
c: do your smarty magic for your next/prev links:

Here is some (very loose) pseudocode.

Code: Select all

{foreach from=$nodelist item='node' name='nodelist'}
  {if $nodelist->current == true}
     {assign value='current_idx' value=$smarty.foreach.nodelist.index}
  {/if}
{/foreach}
{assign var='last_idx' value=$smarty.foreach.nodelist.total - 1}

{if $current_idx > 0}
  {* display link to previous page *}
  <a href="{$nodelist[$current_idx-1]->url}">prev<a>
{/if}
{if $current_idx < $last_idx}
  <a href="{$nodelist[$current_idx+1]->url}">prev</a>
  {* display link to next page *}
{/if}
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
thomsonson
Forum Members
Forum Members
Posts: 39
Joined: Wed Aug 24, 2011 9:47 am

Re: Menu with forward/back and counter

Post by thomsonson »

thanks much for the replies, in the end i am using cgsimplesmarty as follows:

Code: Select all

{$cgsimple->get_sibling("prev","prev_sibling")}{if !empty($prev_sibling)}{cms_selflink page="$prev_sibling" text="Previous"}{/if}
<br>
{$cgsimple->get_sibling("next","next_sibling")}{if !empty($next_sibling)}{cms_selflink page="$next_sibling" text="Next"}{/if}
but I have 2 further questions..

1. how could one best construct a counter, as in page 2 of 4 for example, for the siblings pages. Is this possible with simplesmarty? or can the {$friendly_position} and {$count} tags be used in some way to count only the siblings of a certain page (rather than the entire menu)?

2. Could the code above be modified so that 'next' link stays visible on the final sibling page and links back to the first sibling (and vice versa at the other end)?
Post Reply

Return to “Layout and Design (CSS & HTML)”