Need Little help with pagination

Discussion in 'Apache' started by badeyes, Nov 13, 2009.

  1. #1
    I am stuck with pagination. how do i change the url from: hxxp://www.example.com/software/?page=2 to hxxp://www.example.com/software/page2/ or hxxp://www.example.com/software/2/

    and I can't access the second page. So I just need little help with this. Someone can change the pagination code/variables from /?page=2 to /page2/ or /2/.

    Here's the page control code:

    {*
    * @param array $pagedata
    * @param string $url_base
    * @param string $url_add must contain %page% record for replacing with page number
    * @param string $url_clear
    * @param string $url must contain %page% record for replacing with page number
    *}

    {if $pagedata}
    <br/>
    <div align="center">
    {if $pagedata.prev}
    <a href="{if $url}{$url|replace:"%page%":$pagedata.prev}{else}{url url=$url_base clear=$url_clear add=$url_add|replace:"%page%":$pagedata.prev}{/if}">&lt;&lt; prev</a>&nbsp;
    {/if}
    {foreach from=$pagedata.pages item="page" key="num"}
    {if $page.spacer}...{elseif $pagedata.current==$num}<b>{$num}</b>{else}<a href="{if $url}{$url|replace:"%page%":$num}{else}{url url=$url_base clear=$url_clear add=$url_add|replace:"%page%":$num}{/if}">{$num}</a>{/if}&nbsp;
    {/foreach}
    {if $pagedata.next}
    <a href="{if $url}{$url|replace:"%page%":$pagedata.next}{else}{url url=$url_base clear=$url_clear add=$url_add|replace:"%page%":$pagedata.next}{/if}" >next &gt;&gt;</a>
    {/if}
    </div>
    <br/>
    {/if}

    Thanks
     
    Last edited: Nov 13, 2009
    badeyes, Nov 13, 2009 IP
  2. badeyes

    badeyes Active Member

    Messages:
    411
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    55
    #2
    oh, i forgot to add this code, i need to change the /?page=2 to /page2/ or /2/

    function make_pages($params) {
    $cur_page = $params['cur_page'];
    $items = $params['items'];
    $visible = $params['visible'] ? $params['visible'] : 5;
    $items_per_page = $params['items_per_page'];
    if (!$cur_page)
    $cur_page = 1;
    $pages_num =(int)ceil($items/$items_per_page);
    $start = 1;
    $end = $pages_num;

    $pages = array();

    for ($i=$start; $i<=$end; $i++) {
    if (($visible>=abs($cur_page-$i)) || ($i==$start) || ($i==$end)) {
    $pages[$i] = array('num'=>$i,'first'=>($i==$start),'last'=>($i==$end),'spacer'=>false);
    $next = $i+1;
    if (($visible<abs($cur_page-$next)) && ($i!=$end) && ($next!=$end))
    $pages[$next] = array('num'=>false,'first'=>false,'last'=>false,'spacer'=>true);
    }
    }

    $prev = $cur_page-1>=$start ? $cur_page-1 : false;
    $next = $cur_page+1<=$end ? $cur_page+1 : false;
    $limit = ($cur_page-1)*$items_per_page.','.$items_per_page;

    return array("pages" => $pages, "current" => $cur_page, 'prev'=>$prev, 'next'=>$next, 'limit'=>$limit);
    }
     
    badeyes, Nov 13, 2009 IP
  3. badeyes

    badeyes Active Member

    Messages:
    411
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    55
    #3
    hello, is there no one to help on this :(
     
    badeyes, Nov 13, 2009 IP
  4. badeyes

    badeyes Active Member

    Messages:
    411
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    55
    #4
    i only want to remove the ? and = querystring from the about code when I want to access the next page.
     
    badeyes, Nov 13, 2009 IP