zoukankan      html  css  js  c++  java
  • phpcms v9 自定义伪静态的分页函数

    因为。这个页面还没做好。。等做好了。。再给大家演示。。。。。。
    
    调用方法:$page_attr=pages_open($num[0]['cun'],$get_page,$max_page,'http://wuhan.qunaerwan.com/jingdian-'.$pieces[0].'-'.$pieces[1].'-'.$pieces[2].'-'.$pieces[3].'-'.$pieces[4].'-'.$pieces[5].'-'.$key.'-');
    
    
    /**
    * 自定义伪静态的分页函数。
    *
    * @param $num 信息总数
    * @param $curr_page 当前分页
    * @param $perpage 每页显示数
    * @param $urlrule URL规则
    * @param $array 需要传递的数组,用于增加额外的方法
    * @return 分页
    */
    function pages_open($num, $curr_page, $perpage = 20, $urlrule = '', $array = array(),$setpages = 10){
        $multipage = '';
        if($num > $perpage) {
            $page = $setpages+1;
            $offset = ceil($setpages/2-1);
            $pages = ceil($num / $perpage);
            if (defined('IN_ADMIN') && !defined('PAGES')) define('PAGES', $pages);
            $from = $curr_page - $offset;
            $to = $curr_page + $offset;
            $more = 0;
            if($page >= $pages) {
                $from = 2;
                $to = $pages-1;
            } else {
                if($from <= 1) {
                    $to = $page-1;
                    $from = 2;
                }  elseif($to >= $pages) {
                    $from = $pages-($page-2);
                    $to = $pages-1;
                }
                $more = 1;
            }
            $multipage .= '<a class="a1">'.$num.L('page_item').'</a>';
       
    
       
            
            if($curr_page>0) {
            
                
                if($curr_page==1) {
                $multipage .= ' <a href="'.$urlrule.$curr_page.'.html" class="a1">'.L('previous').'</a>';
                    $multipage .= ' <span>1</span>';
                } elseif($curr_page>6 && $more) {
                $multipage .= ' <a href="'.$urlrule.($curr_page-1).'.html" class="a1">'.L('previous').'</a>';
                    $multipage .= ' <a href="'.$urlrule.'1.html">1</a>..';
                } else {
                $multipage .= ' <a href="'.$urlrule.($curr_page-1).'.html" class="a1">'.L('previous').'</a>';
                    $multipage .= ' <a href="'.$urlrule.'1.html">1</a>';
                }
            }
            
            for($i = $from; $i <= $to; $i++) {
                if($i != $curr_page) {
                    $multipage .= ' <a href="'.$urlrule.$i.'.html">'.$i.'</a>';
                } else {
                    $multipage .= ' <span>'.$i.'</span>';
                }
            }
            
            if($curr_page<$pages) {
                if($curr_page<$pages-5 && $more) {
                    $multipage .= ' ..<a href="'.$urlrule.$pages.'.html">'.$pages.'</a> <a href="'.$urlrule.($curr_page+1).'.html" class="a1">'.L('next').'</a>';
                } else {
                    $multipage .= ' <a href="'.$urlrule.$pages.'.html">'.$pages.'</a> <a href="'.$urlrule.($curr_page+1).'.html" class="a1">'.L('next').'</a>';
                }
            } elseif($curr_page==$pages) {
                $multipage .= ' <span>'.$pages.'</span> <a href="'.$urlrule.$curr_page.'.html" class="a1">'.L('next').'</a>';
            } else {
                $multipage .= ' <a href="'.$urlrule.$pages.'.html">'.$pages.'</a> <a href="'.$urlrule.$curr_page.'.html" class="a1">'.L('next').'</a>';
            }
            
            
        }
        return $multipage;
    }
  • 相关阅读:
    Solr的中英文分词实现
    乐观锁与悲观锁
    Keepalived + nginx实现高可用性和负载均衡
    Heartbeat实现集群高可用热备
    mongoDB 使用手册
    LVS+keepalived负载均衡
    keepalived工作原理和配置说明
    微信设置URL之WebApi方式
    RabbitMQ Windows下安装问题解决
    JSOM 中对各种字段操作
  • 原文地址:https://www.cnblogs.com/wawahaha/p/3581279.html
Copyright © 2011-2022 走看看