Smarty and page count navigation
Posted: Sat Feb 09, 2013 7:04 pm
Hi,
I have searched through the forums and found a couple of solutions to my question, but not really quite what I need. I have a very lengthy amount of page content that needs to be separated into several pages. I wanted to include "previous" and "next" with also "page 1 of 5", "page 2 of 5", etc. for the sibling pages.
I pieced together the following code for this purpose:
<div>
<div>
{$cgsimple->get_sibling("prev","prev_sibling")}
{if !empty($prev_sibling)}
{cms_selflink page="$prev_sibling" text="Previous Page"} :: {page_attr key="extra1"} of 5
{/if}
{$cgsimple->get_sibling("next","next_sibling")}
{if empty($prev_sibling)}{page_attr key="extra1"} of 5 :: {cms_selflink page="$next_sibling" text="Next Page"}
{elseif !empty($prev_sibling) AND !empty($next_sibling)} :: {cms_selflink page="$next_sibling" text="Next Page"}
{elseif !empty($next_sibling)}{cms_selflink page="$next_sibling" text="Next Page"}{/if}
</div>
</div>
My questions are:
1. Is there a different, or easier way to do this?
2. How do I write in for the smarty to count the sibling pages, so I could apply this more broadly?
(I'm not very good at writing smarty) I appreciate any input or suggestions. Thank you! Camille
I have searched through the forums and found a couple of solutions to my question, but not really quite what I need. I have a very lengthy amount of page content that needs to be separated into several pages. I wanted to include "previous" and "next" with also "page 1 of 5", "page 2 of 5", etc. for the sibling pages.
I pieced together the following code for this purpose:
<div>
<div>
{$cgsimple->get_sibling("prev","prev_sibling")}
{if !empty($prev_sibling)}
{cms_selflink page="$prev_sibling" text="Previous Page"} :: {page_attr key="extra1"} of 5
{/if}
{$cgsimple->get_sibling("next","next_sibling")}
{if empty($prev_sibling)}{page_attr key="extra1"} of 5 :: {cms_selflink page="$next_sibling" text="Next Page"}
{elseif !empty($prev_sibling) AND !empty($next_sibling)} :: {cms_selflink page="$next_sibling" text="Next Page"}
{elseif !empty($next_sibling)}{cms_selflink page="$next_sibling" text="Next Page"}{/if}
</div>
</div>
My questions are:
1. Is there a different, or easier way to do this?
2. How do I write in for the smarty to count the sibling pages, so I could apply this more broadly?
(I'm not very good at writing smarty) I appreciate any input or suggestions. Thank you! Camille