|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
gmilby Smarty Rookie
Joined: 18 Dec 2011 Posts: 12
|
Posted: Fri Jan 06, 2012 9:53 pm Post subject: how can smarty paginate plugin be used with tinymvc? |
|
|
looks like the example is using a static php file with direct requires.
anyone know how this plugin can be integrated into tinymvc
thanks
(re:http://www.phpinsider.com/php/code/SmartyPaginate/) |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Fri Jan 06, 2012 10:57 pm Post subject: |
|
|
its just a smarty plugin, first integrate smarty with tinymvc (instructions in the tinymvc docs) |
|
Back to top |
|
gmilby Smarty Rookie
Joined: 18 Dec 2011 Posts: 12
|
Posted: Sat Jan 07, 2012 2:53 am Post subject: roll your(my) own... o.0 |
|
|
mohrt wrote: | its just a smarty plugin, first integrate smarty with tinymvc (instructions in the tinymvc docs) |
the class seemed like a lot more comments than code (which was good - just learned how to do it from the comments and made my own - i hope o.0)
CONTROLLER:
Code: |
$total_count=$this->quotes->countQuotes();
$page_number=(isset($page_number))?$page_number:1;
$per_page=(isset($per_page))?$per_page:'5';
$total_pages=ceil($total_count/$per_page); //total_pages
$curr_offset=($page_number-1)*$per_page;
$limit_offset=Array(
'limit'=>$per_page
,'offset'=>$curr_offset
);
$quotes_payload=$this->quotes->getQuotes($limit_offset);
$page_nums=Array(
'page_number'=>$page_number
,'total_pages'=>$total_pages
); |
TPL:
Code: |
<div id="page_nums" align="center" style="margin:10px;">
<!-- first -->
{if $page_nums['page_number']===1}
<a href="#" id="paginate" class="first disabled_button">First</a>
{else}
{if ($page_nums['page_number']-1)==0}
<a href="#" id="paginate" class="first disabled_button">First</a>
{else}
<a href="/quotes/page/1/" id="paginate">First</a>
{/if}
{/if}
<!-- prev -->
{if (($page_nums['page_number'])>=($page_nums['page_number']+1))}
<a href="#" id="paginate" class="first disabled_button">Prev</a>
{else}
{if ($page_nums['page_number']-1)==0}
<a href="#" id="paginate" class="first disabled_button">Prev</a>
{else}
<a href="/quotes/page/{($page_nums['page_number']-1)}/" id="paginate">Prev</a>
{/if}
{/if}
<!-- next -->
{if ($page_nums['page_number'])<=($page_nums['total_pages']-1)}
<a href="/quotes/page/{($page_nums['page_number']+1)}/" id="paginate">Next</a>
{else}
<a href="#" id="paginate" class="first disabled_button">Next</a>
{/if}
<!-- last -->
{if $page_nums['page_number']<=($page_nums['total_pages']-1)}
<a href="/quotes/page/{$page_nums['total_pages']}/" id="paginate">Last</a>
{else}
<a href="#" id="paginate" class="first disabled_button">Last</a>
{/if}
</div> |
|
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|