Previous and next links only for the current item
Posted: Fri Jul 03, 2009 11:18 am
I wanted previous and next links that only showed me pages within the current hierarchy.
Thanks to hematec who I took the majority of this code from.
http://forum.cmsmadesimple.org/index.php?topic=34180.0
Create a UDT called hierarchy
global $gCms;
$pos = $gCms->variables['position'];
$base = explode('.', $pos);
$smarty->assign('h_toplevel', $base[0] * 1);
$smarty->assign('h_parent', $base[ (count($base) > 1) ? count($base)-2 : 0 ] * 1);
$smarty->assign('h_this', $base[count($base)-1] * 1);
$smarty->assign('h_level', count($base) * 1);
$smarty->assign('f_position', $gCms->variables['friendly_position']);
$smarty->assign('f_base', (int)$gCms->variables['friendly_position']);
and put this in your template
{hierarchy}
{assign var="NewLevel" value=$h_level+1}
{assign var='count' value=0}
{assign var="f_pos_next" value=$f_position+0.1}
{assign var="f_pos_prev" value=$f_position-0.1}
{assign var="f_base" value=$f_base}
{assign var="f_ceil" value=$f_base+1}
{if $NewLevel > 1}
{if $f_pos_next {menu template='V2 Main Menu' start_element=$f_pos_next number_of_levels="1"}
{/if}
{if $f_pos_prev >= $f_base}
{menu template='V2 Main Menu' start_element=$f_pos_prev number_of_levels="1"}
{/if}
{/if}
Thanks to hematec who I took the majority of this code from.
http://forum.cmsmadesimple.org/index.php?topic=34180.0
Create a UDT called hierarchy
global $gCms;
$pos = $gCms->variables['position'];
$base = explode('.', $pos);
$smarty->assign('h_toplevel', $base[0] * 1);
$smarty->assign('h_parent', $base[ (count($base) > 1) ? count($base)-2 : 0 ] * 1);
$smarty->assign('h_this', $base[count($base)-1] * 1);
$smarty->assign('h_level', count($base) * 1);
$smarty->assign('f_position', $gCms->variables['friendly_position']);
$smarty->assign('f_base', (int)$gCms->variables['friendly_position']);
and put this in your template
{hierarchy}
{assign var="NewLevel" value=$h_level+1}
{assign var='count' value=0}
{assign var="f_pos_next" value=$f_position+0.1}
{assign var="f_pos_prev" value=$f_position-0.1}
{assign var="f_base" value=$f_base}
{assign var="f_ceil" value=$f_base+1}
{if $NewLevel > 1}
{if $f_pos_next {menu template='V2 Main Menu' start_element=$f_pos_next number_of_levels="1"}
{/if}
{if $f_pos_prev >= $f_base}
{menu template='V2 Main Menu' start_element=$f_pos_prev number_of_levels="1"}
{/if}
{/if}