forward and back links that go through every page even if they set not to show

Do something cool with CMS? Show us ...
This board is for 'Answers', and the discussion of answers... Not for questions.
Post Reply
gap_tooth_clan

forward and back links that go through every page even if they set not to show

Post by gap_tooth_clan »

First you need to install cgsimplesmarty and i would choose to make these Global Content Blocks

Previous link

Code: Select all

{$cgsimple->get_sibling("prev","prev_sibling")}

{* check there is a previous sibling *}
{if !empty($prev_sibling)}

	{$cgsimple->has_children($prev_sibling, 'prev_has_children')}
	
	{* check previous sibling has a child then retrieve last child *}
	
	{if !empty($prev_has_children)}
		{$cgsimple->get_children($prev_sibling, true, "prev_get_children")}
		
		{capture assign="prevLastChild"}{$prev_get_children|@count}{/capture}
		
		 {capture assign="prevArrayLast"}{math equation="x - 1" x=$prevLastChild}{/capture}
		
		{capture assign="prevGotChild"}{$prev_get_children[$prevArrayLast].alias}{/capture}
		
		{capture assign="prevGotChildTitle"}{$prev_get_children[$prevArrayLast].title}{/capture}
		
		{cms_selflink page="$prevGotChild" text="Prev"}
	
	{else}
	{* Just show previous link as there are no children *}
		{if !empty($prev_sibling)}
		{cms_selflink page="$prev_sibling" text="$prevGotChildTitle"}
		{/if}
	
	{/if}
{else}
		{$cgsimple->get_parent_alias("","prev_parent_alias")}
		{if !empty($prev_parent_alias)}
		{$cgsimple->get_page_title($prev_parent_alias, 'prev_parent_title')}
		{cms_selflink page="$prev_parent_alias" text="$prev_parent_title"}{/if}
{/if}	
Next link

Code: Select all

{$cgsimple->has_children('', 'has_children')}

{if !empty($has_children)}

	{$cgsimple->get_children("",true, "get_children")}
	{capture assign="gotChild"}{$get_children[0].alias}{/capture}
	{capture assign="gotChildTitle"}{$get_children[0].title}{/capture}
	{cms_selflink page="$gotChild" text="$gotChildTitle"}
	
{else}

	{$cgsimple->get_sibling("next","next_sibling")}
	{if !empty($next_sibling)}
	{cms_selflink page="$next_sibling" text="Next"}{/if}
	
{/if}
Post Reply

Return to “Tips and Tricks”