in reply to Navigation script?
Perl style:
my $current_page_num = 2; my $num_pages = 6; if ($current_page_num > 1) { ...display link to page $current_page_num-1... } for my $page_num (1 .. $num_pages) { if ($page_num == $current_page_num) { ...display page number... } else { ...display link to page $page_num... } } if ($current_page_num < $num_pages) { ...display link to page $current_page_num+1... }
Or template style:
(Whitespace added for readability.)
(The template system I use looks at the class for commands.)
<a class="if::Selector.link_prev sub::href::Selector.link_prev" href="{page_link_next}" ><<Prev</a> <span class="page_selector_cell"> <span class="if::Selector.Page.is_current text::Selector.Page.page_num current-page" >{page num}</span> <a class="unless::Selector.Page.is_current sub::href::Selector.Page.link text::Selector.Page.page_num" href="{page_link}" >{page num}</a> </span> <a class="if::Selector.link_next sub::href::Selector.link_next" href="{page_link_next}" >Next>gt;</a>
given
Selector.link_prev -> Link to prev page, if any. Selector.link_next -> Link to next page, if any. page_selector_cell -> Loops over all page nums, setting these: Selector.Page.is_current -> True if page_num is current page. Selector.Page.page_num -> Loop variable. Selector.Page.link -> Link to page page_num.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Navigation script?
by bobafifi (Beadle) on Mar 11, 2005 at 20:32 UTC |