Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.

how can smarty paginate plugin be used with tinymvc?

 
Post new topic   Reply to topic    Smarty Forum Index -> Plugins
View previous topic :: View next topic  
Author Message
gmilby
Smarty Rookie


Joined: 18 Dec 2011
Posts: 12

PostPosted: Fri Jan 06, 2012 9:53 pm    Post subject: how can smarty paginate plugin be used with tinymvc? Reply with quote

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
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7366
Location: Lincoln Nebraska, USA

PostPosted: Fri Jan 06, 2012 10:57 pm    Post subject: Reply with quote

its just a smarty plugin, first integrate smarty with tinymvc (instructions in the tinymvc docs)
Back to top
View user's profile Send private message Visit poster's website
gmilby
Smarty Rookie


Joined: 18 Dec 2011
Posts: 12

PostPosted: Sat Jan 07, 2012 2:53 am    Post subject: roll your(my) own... o.0 Reply with quote

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>&nbsp;
      {else}
         {if ($page_nums['page_number']-1)==0}
            <a href="#" id="paginate" class="first disabled_button">First</a>&nbsp;
         {else}
            <a href="/quotes/page/1/" id="paginate">First</a>&nbsp;
         {/if}
      {/if}   
<!-- prev -->
      {if (($page_nums['page_number'])>=($page_nums['page_number']+1))}         
         <a href="#" id="paginate" class="first disabled_button">Prev</a>&nbsp;         
      {else}
         {if ($page_nums['page_number']-1)==0}
            <a href="#" id="paginate" class="first disabled_button">Prev</a>&nbsp;
         {else}
            <a href="/quotes/page/{($page_nums['page_number']-1)}/" id="paginate">Prev</a>&nbsp;
         {/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>&nbsp;
      {else}
         <a href="#" id="paginate" class="first disabled_button">Next</a>&nbsp;
      {/if}   
      
<!-- last -->      
      {if $page_nums['page_number']<=($page_nums['total_pages']-1)}
         <a href="/quotes/page/{$page_nums['total_pages']}/" id="paginate">Last</a>&nbsp;
      {else}
         <a href="#" id="paginate" class="first disabled_button">Last</a>&nbsp;
      {/if}      
   </div>
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Plugins All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP