【问题标题】:codeigniter pagination customizingcodeigniter 分页定制
【发布时间】:2011-01-04 07:13:57
【问题描述】:

我正在浏览 CI 文档,尤其是 http://codeigniter.com/user_guide/libraries/pagination.html

我想到的第一件事是“CodeIgniter 的 Pagination 类非常易于使用,而且它是 100% 可定制的,无论是动态的还是通过存储的首选项。”但总有一些东西。

我的分页如下Previous 1 2 3 4 ... n Next,现在我可以在我的控制器中创建打开的html标签和关闭的html标签。

例如:

上一页

$config['prev_tag_open'] = '<div class="previous">';

The opening tag for the "previous" link.
$config['prev_tag_close'] = '</div>';

下一个

$config['next_tag_open'] = '<div>';

The opening tag for the "next" link.
$config['next_tag_close'] = '</div>';

对于 Last first 等等。现在在我的设计中,我将 Previous float left Next 向右浮动,我有一个 &lt;div class="middle_pager"&gt;,它将所有页码放在中间。

从我在文档中看到的内容来看,我在 CI 中没有将所有页码放在 html 标签之间的选项,我只能选择将每个页码放在一些标签中,也许有办法但我错过了一个点。有人可以帮忙吗?

谢谢

【问题讨论】:

    标签: html model-view-controller codeigniter


    【解决方案1】:

    这很难解决问题,您将如何处理第一页和最后一页的这种情况? next_tag_open/close 不会出现在分页的最后一页,prev_tag_open/close 不会出现在分页的第一页。

    这显然会导致这些页面的两个块元素都被破坏

    好的,所以我今天早些时候遇到了同样的问题,它真的让我很头疼。我想出的唯一解决方案(完美运行)就是这个;

    围绕输出创建一个 div -

    <div class="pagination2">
        <?php echo $link; ?>
    </div>
    

    然后使用类提供的分页标签围绕使用这些标签来环绕数字标签(num_tag_open/close)。

    $config['full_tag_open'] = '<div class="pagination">'; $config['full_tag_close'] = '</div>'; $config['num_tag_open'] = '<p>; $config['num_tag_close'] = '</p>';

    现在跳转到 css 并相对定位外部块元素 pagination2,然后去绝对定位内部块类分页,将其居中,然后您可以使用负值推送绝对定位的 nextlink 或 prevlink 元素。我使用的 css 见下文。

     .pagination2{
      position: relative;
      right: -10px;
      height: 45px;
      width: 500px;
      background-color:#f8f8f8;
      border: 1px solid #d3d3d3;    
      outline:none;
      }
    
      .pagination{
      position: absolute;
      left: 180px;
      height: 35px;
      width: 120px;
      }
    
      .pagination-button-previous{   
        position: absolute;
        top: 10px;
        left: -160px;
        width: 74px;
        height: 24px;
    

    【讨论】:

    • 欢迎堆栈溢出!感谢您完成此答案。
    【解决方案2】:

    诀窍在于,您必须跳出框框思考。

    您应该在“prev_tag_close”的末尾添加一个开始标签

    $config['prev_tag_open'] = '<div class="previous">';
    
    The opening tag for the "previous" link.
    $config['prev_tag_close'] = '</div>**<opening tag>**';
    

    在你的“next_tag_open”处有一个结束标签,比如

    $config['next_tag_open'] = '**</opening tag>**<div>';
    
    The opening tag for the "next" link.
    $config['next_tag_close'] = '</div>';
    

    这应该可以解决问题。

    【讨论】:

      猜你喜欢
      • 2013-03-28
      • 1970-01-01
      • 2011-08-21
      • 2016-11-23
      • 1970-01-01
      • 2017-11-08
      • 1970-01-01
      相关资源
      最近更新 更多