Difference between revisions of "Print page numbers"
From TMM Wiki
Jump to navigationJump to search (Created page with '{{CARMA1 Manual | show_template_functions_section = true }} = print_page_numbers = * Purpose: Output page number links to content instead of just 'next' and 'previous' links * U…') |
|||
(7 intermediate revisions by 4 users not shown) | |||
Line 5: | Line 5: | ||
= print_page_numbers = | = print_page_numbers = | ||
* Purpose: Output page number links to content instead of just 'next' and 'previous' links | * Purpose: Output page number links to content instead of just 'next' and 'previous' links | ||
− | * Usage: { | + | * Usage: {print_page_numbers start=$params.start count=$params.count total=$carma_content_count} |
− | * Required: | + | * Required: total |
− | |||
* Version: 1.4 or greater | * Version: 1.4 or greater | ||
* Default Templates Used: page_numbers | * Default Templates Used: page_numbers | ||
Line 21: | Line 20: | ||
! Default Value | ! Default Value | ||
! Example | ! Example | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
|- | |- | ||
| [[count]] | | [[count]] | ||
− | | | + | | How many of the content do we display per page |
| Zero or any whole number greater than zero | | Zero or any whole number greater than zero | ||
− | | | + | | 12 |
− | | count= | + | | count=$params.count |
|- | |- | ||
| [[start]] | | [[start]] | ||
− | | | + | | What number did the content start displaying at |
+ | | Any whole number greater than zero | ||
+ | | ''0'' | ||
+ | | start=$params.start | ||
+ | |- | ||
+ | | [[total]] | ||
+ | | The total amount of content found | ||
| Any whole number greater than zero | | Any whole number greater than zero | ||
| ''None.'' (Doesn't hide any results) | | ''None.'' (Doesn't hide any results) | ||
− | | | + | | total=$carma_content_count |
|- | |- | ||
− | | | + | | [[tpl]] |
− | | | + | | Template to use for showing the output |
− | | Any | + | | Any template that you want to show page numbers |
− | | | + | | When no tpl set, page_numbers is used |
− | | | + | | tpl="my_template" |
|- | |- | ||
− | | | + | | [[show_pages]] |
− | | The | + | | The amount of page numbers to display to the users |
− | | | + | | Any whole number greater than zero |
− | | | + | | ''9.'' |
− | | | + | | show_pages=9 |
|- | |- | ||
− | | | + | | [[current_page]] |
− | | | + | | The current page that is being shown |
− | | | + | | Any whole number greater than zero |
− | | | + | | Will be calculated on the fly |
− | | | + | | current_page=5 |
|- | |- | ||
− | | | + | | [[total_pages]] |
− | | | + | | Total amount of pages that exist |
− | + | | Any whole number greater than zero | |
− | + | | Will be calculated on the fly | |
− | + | | total_pages=65 | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | | Any | ||
− | | | ||
− | | | ||
|} | |} | ||
== Description == | == Description == | ||
− | This function | + | This function will output a list of page numbers on your website so users can more easily navigate through your content. |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | == Example == | + | == Example Template == |
<pre> | <pre> | ||
− | { | + | <div class='video_pages'> |
+ | <div class='video_pages-big'>PAGE {$page_params.current_page} OF {$page_params.total_pages}</div> | ||
+ | |||
+ | {if $page_params.current_page > 1 } | ||
+ | <div class='video_pages-big'><a href='{rebuild_link using="GET" without="start,count"}&start=0&count={$page_params.count}'><< FIRST</a></div> | ||
+ | <div class='video_pages-big'><a href='{rebuild_link using="GET" without="start,count"}&start={math equation="x-y" x=$page_params.start y=$page_params.count}&count={$page_params.count}'>< PREVIOUS</a></div> | ||
+ | {else} | ||
+ | <div class='video_pages-big'><< FIRST</div> | ||
+ | <div class='video_pages-big'>< PREVIOUS</div> | ||
+ | {/if} | ||
+ | |||
+ | {foreach from=$page_numbers item=page_info} | ||
+ | {if $page_params.current_page == $page_info.page} | ||
+ | <div class='video_pages-active'>{$page_info.page}</div> | ||
+ | {else} | ||
+ | <div class='video_pages-small'><a href='{rebuild_link using="GET" without="start,count"}&start={$page_info.start}&count={$page_params.count}'>{$page_info.page}</a></div> | ||
+ | {/if} | ||
+ | {/foreach} | ||
+ | |||
+ | {if $page_params.current_page < $page_params.total_pages } | ||
+ | <div class='video_pages-big'><a href='{rebuild_link using="GET" without="start,count"}&start={math equation="x+y+1" x=$page_params.start y=$page_params.count}&count={$page_params.count}'>NEXT ></a></div> | ||
+ | <div class='video_pages-big'><a href='{rebuild_link using="GET" without="start,count"}&start={math equation="(x-1)*y" x=$page_params.total_pages y=$page_params.count}&count={$page_params.count}'>LAST >></a></div> | ||
+ | {else} | ||
+ | <div class='video_pages-big'>NEXT ></div> | ||
+ | <div class='video_pages-big'>LAST >></div> | ||
+ | {/if} | ||
+ | </div> | ||
+ | </pre> | ||
− | + | == Example Function Call == | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | <pre> | |
− | + | {print_page_numbers start=$params.start count=$params.count total=$carma_content_count} | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
</pre> | </pre> |
Latest revision as of 11:27, 20 December 2011
print_page_numbers
- Purpose: Output page number links to content instead of just 'next' and 'previous' links
- Usage: {print_page_numbers start=$params.start count=$params.count total=$carma_content_count}
- Required: total
- Version: 1.4 or greater
- Default Templates Used: page_numbers
- Variables created: $first_page, $last_page, $current_page, $total_pages, $page_params
Parameters
(Required parameters in bold)
Parameter | Description | Possible Values | Default Value | Example |
---|---|---|---|---|
count | How many of the content do we display per page | Zero or any whole number greater than zero | 12 | count=$params.count |
start | What number did the content start displaying at | Any whole number greater than zero | 0 | start=$params.start |
total | The total amount of content found | Any whole number greater than zero | None. (Doesn't hide any results) | total=$carma_content_count |
tpl | Template to use for showing the output | Any template that you want to show page numbers | When no tpl set, page_numbers is used | tpl="my_template" |
show_pages | The amount of page numbers to display to the users | Any whole number greater than zero | 9. | show_pages=9 |
current_page | The current page that is being shown | Any whole number greater than zero | Will be calculated on the fly | current_page=5 |
total_pages | Total amount of pages that exist | Any whole number greater than zero | Will be calculated on the fly | total_pages=65 |
Description
This function will output a list of page numbers on your website so users can more easily navigate through your content.
Example Template
<div class='video_pages'> <div class='video_pages-big'>PAGE {$page_params.current_page} OF {$page_params.total_pages}</div> {if $page_params.current_page > 1 } <div class='video_pages-big'><a href='{rebuild_link using="GET" without="start,count"}&start=0&count={$page_params.count}'><< FIRST</a></div> <div class='video_pages-big'><a href='{rebuild_link using="GET" without="start,count"}&start={math equation="x-y" x=$page_params.start y=$page_params.count}&count={$page_params.count}'>< PREVIOUS</a></div> {else} <div class='video_pages-big'><< FIRST</div> <div class='video_pages-big'>< PREVIOUS</div> {/if} {foreach from=$page_numbers item=page_info} {if $page_params.current_page == $page_info.page} <div class='video_pages-active'>{$page_info.page}</div> {else} <div class='video_pages-small'><a href='{rebuild_link using="GET" without="start,count"}&start={$page_info.start}&count={$page_params.count}'>{$page_info.page}</a></div> {/if} {/foreach} {if $page_params.current_page < $page_params.total_pages } <div class='video_pages-big'><a href='{rebuild_link using="GET" without="start,count"}&start={math equation="x+y+1" x=$page_params.start y=$page_params.count}&count={$page_params.count}'>NEXT ></a></div> <div class='video_pages-big'><a href='{rebuild_link using="GET" without="start,count"}&start={math equation="(x-1)*y" x=$page_params.total_pages y=$page_params.count}&count={$page_params.count}'>LAST >></a></div> {else} <div class='video_pages-big'>NEXT ></div> <div class='video_pages-big'>LAST >></div> {/if} </div>
Example Function Call
{print_page_numbers start=$params.start count=$params.count total=$carma_content_count}