thinkPHP5.1框架使用SemanticUI实现分页功能示例
ThinkPHP  /  管理员 发布于 9年前   247
             本文实例讲述了thinkPHP5.1框架使用SemanticUI实现分页功能。分享给大家供大家参考,具体如下: 1、config目录下新建paginate.php,下面是文件的内容 2、thinkphp\library\think\paginator\driver\下新建Semantic.php,下面是文件的内容 122 在 123 在 原梓番博客 在 博主 在 1111 在 'Semantic',    'var_page' => 'page',  ];
';  private static $nextButtonHtml = '';  /**   * 上一页按钮   * @return string   */  protected function getPreviousButton() {    if ($this->currentPage() <= 1) {      return $this->getDisabledTextWrapper(Semantic::$previousButtonHtml);    }    $url = $this->url(      $this->currentPage() - 1    );    return $this->getPageLinkWrapper($url, Semantic::$previousButtonHtml);  }  /**   * 下一页按钮   * @return string   */  protected function getNextButton() {    if (!$this->hasMore) {      return $this->getDisabledTextWrapper(Semantic::$nextButtonHtml);    }    $url = $this->url($this->currentPage() + 1);    return $this->getPageLinkWrapper($url, Semantic::$nextButtonHtml);  }  /**   * 页码按钮   * @return string   */  protected function getLinks() {    $block = [      'first' => null,      'slider' => null,      'last'  => null    ];    $side  = 3;    $window = $side * 2;    if ($this->lastPage < $window + 6) {      $block['first'] = $this->getUrlRange(1, $this->lastPage);    } elseif ($this->currentPage <= $window) {      $block['first'] = $this->getUrlRange(1, $window + 2);      $block['last'] = $this->getUrlRange($this->lastPage - 1, $this->lastPage);    } elseif ($this->currentPage > ($this->lastPage - $window)) {      $block['first'] = $this->getUrlRange(1, 2);      $block['last'] = $this->getUrlRange($this->lastPage - ($window + 2), $this->lastPage);    } else {      $block['first'] = $this->getUrlRange(1, 2);      $block['slider'] = $this->getUrlRange($this->currentPage - $side, $this->currentPage + $side);      $block['last']  = $this->getUrlRange($this->lastPage - 1, $this->lastPage);    }    $html = '';    if (is_array($block['first'])) {      $html .= $this->getUrlLinks($block['first']);    }    if (is_array($block['slider'])) {      $html .= $this->getDots();      $html .= $this->getUrlLinks($block['slider']);    }    if (is_array($block['last'])) {      $html .= $this->getDots();      $html .= $this->getUrlLinks($block['last']);    }    return $html;  }  /**   * 渲染分页html   * @return mixed   */  public function render() {    if ($this->hasPages()) {      if ($this->simple){        return sprintf(          '
						
			Copyright·© 2019 侯体宗版权所有·
			粤ICP备20027696号
			 
			
