Implementation of smarty Simple Paging

  • 2021-07-22 09:13:26
  • OfStack

This article describes the example of smarty simple paging implementation method, to share for your reference. The specific implementation method is as follows:

The following is the smarty code in the template. It is very simple to substitute the related variables with smarty, but the parameter page is also passed in the php code. I think this division is quite good and very simple. I like to use smarty more and more.

The Php code is as follows:

{if $pageCount > 1}  
{foreach  item=i from=$pagerList} 
  {if $pageNum eq $i} 
  {$i}   
  {else} 
<a href ="/space/index.php?uid={$userId}&page={$i}">{$i}</a>   
{/if} 
{/foreach} 
{if $pageNum eq 1} 
Upper 1 Page    
{else} 
<a href ="/space/friendlist.php?uid={$userId}&page={$pagePre}"> Upper 1 Page </a>   
{/if} 
{if $pageNum eq $pageCount } 
Under 1 Page    
{else} 
<a href ="/space/friendlist.php?uid={$userId}&page={$pageNext}"> Under 1 Page </a>   
{/if} 
{if $pageNum eq 1} 
Home page    
{else} 
<a href ="/space/friendlist.php?uid={$userId}&page=1"> Home page </a>   
{/if} 
          
{if $pageNum eq $pageCount} 
Finally 1 Page    
{else} 
<a href ="/space/friendlist.php?uid={$userId}&page={$pageCount}"> Finally 1 Page </a>   
{/if} 
{/if} 
(Total {$pageCount} Page)

Here is just one idea. In fact, paging is not so complicated.

I hope this article is helpful to everyone's PHP programming.


Related articles: