• twitter image
  • facebook image
  • youtube image
  • linkedin image
Language: CMS Made Simple Czech CMS Made Simple France CMS Made Simple Spain CMS Made Simple Hungary CMS Made Simple Russia CMS Made Simple Netherlands

All times are UTC




Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: CGFeedback pagination (1 - 2 - 3 ... 4 - 5) with Smarty
PostPosted: Sun Mar 23, 2014 3:08 pm 
Offline
Power Poster
Power Poster

Joined: Sun Dec 28, 2008 12:15 pm
Posts: 448
Location: Roma, Italy
I used CGFeedback to make a Guestbook page, and I needed to paginate posts using pages' numbers (1-2-3 ... 4-5 etc.)
Here a solution, based on these posts (cmsms forum and serendipity forum).
Example:
$1:
pagination_example.jpg
pagination_example.jpg [ 15.4 KiB | Viewed 1990 times ]


Smarty code
\$1:
<!-- Pagination -->   
{if $pagecount>1}
   {if $pagenum < $pagecount}
      {capture assign=pageurl}
         {$nextpage_url}
      {/capture}
   {else}
      {capture assign=pageurl}
         {$prevpage_url}
      {/capture}
   {/if}
   <div class="paging">
{* begin PAGE NUMBERS *}
      <ul class="left">
         <li>
            <h5 class="bold">Page</h5>
         </li>
         {eval var=($pagenum-3) assign="paginationStartPage"}
         {if $pagenum+3 > $pagecount}
            {eval var=($pagecount-6) assign="paginationStartPage"}
         {/if}
         {if $paginationStartPage <= 0}
            {assign var="paginationStartPage" value="1"}
         {/if}
         {if $paginationStartPage > 1}
            <li><a href="{$pageurl|regex_replace:'/pagenum=(\d+)/':'pagenum=1'}" class="backcolrhover">1</a></li>
         {/if}
         {if $paginationStartPage > 2}
            <li>&hellip;</li>
         {/if}
         {section name=i start=$paginationStartPage loop=$pagecount+1 max=7}
            {if $smarty.section.i.index != $pagenum}
               {capture assign=pagestr}
                  pagenum={$smarty.section.i.index}
               {/capture}
               <li>
                  <a href="{$pageurl|regex_replace:'/pagenum=(\d+)/':$pagestr}" class="backcolrhover">{$smarty.section.i.index}</a>
               </li>
               {else}
               {* CURRENT PAGE*}
                  <li><span class="backcolr">{$smarty.section.i.index}</span></li>
            {/if}
         {/section}
         {if $smarty.section.i.index < $pagecount}
            <li>&hellip;</li>
         {/if}
         {if $smarty.section.i.index <= $pagecount}
            {capture assign=pagestr}
               pagenum={$pagecount}
            {/capture}
            <li><a href="{$pageurl|regex_replace:'/pagenum=(\d+)/':$pagestr}" class="backcolrhover">{$pagecount}</a></li>
         {/if}
      </ul>
{* end PAGE NUMBERS *}
{* begin PREVIOUS - NEXT buttons *}
      <ul class="right">
         {if $pagenum > 1}
            <li>
               <a href="{$prevpage_url}" class="prevbtn backcolrhover">Previous</a>
            </li>
         {/if}
         {if $pagenum < $pagecount}
            <li>
               <a href="{$nextpage_url}" class="nextbtn backcolrhover">Next</a>
            </li>
         {/if}
      </ul>
{* end PREVIOUS - NEXT buttons *}
   </div>
{/if}   
<!--  END Pagination -->

CSS
\$1:
.paging {
    float: left;
    padding: 0 0 10px;
    width: 100%;
}
.paging ul {
    list-style: none outside none;
    padding-right: 15px;
}
.paging ul li {
    float: left;
    padding-left: 5px;
}
.paging ul li h5 {
    padding: 3px 10px 0;
}
.paging a {
    border-radius: 3px;
    color: #979797;
    display: block;
    font-size: 12px;
    font-weight: bold;
    height: 20px;
    padding: 4px 10px 0;
}
.paging a:hover {
    color: #FFFFFF;
}
.paging a.backcolr {
    color: #FFFFFF;
}
.paging a.prevbtn, .paging a.nextbtn {
    background-color: #C4C4C4;
    color: #FFFFFF;
}
.left {
    float: left !important;
}
.backcolr {
    background-color: #00417E !important;
}
.backcolrhover:hover {background-color:#00417e !important;}


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: CGFeedback pagination (1 - 2 - 3 ... 4 - 5) with Smarty
PostPosted: Sun Mar 23, 2014 3:49 pm 
Offline
Dev Team Member
Dev Team Member
User avatar

Joined: Wed Apr 23, 2008 7:53 am
Posts: 7708
Location: The Netherlands
Nice, thanks for sharing!

Grtz. Rolf

_________________
$1

Did my post help you solving a problem at your (customers) website and it saved you many hours of work? Great!! Consider buying me a cup of coffee in return!



Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
Display posts from previous:  Sort by  
Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users


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 post attachments in this forum

Search for:
Jump to:  
Hosting Nation - Managed CMSMS Hosting