2010-01-12 99 views
0

我在浏览槽文件,特别是http://codeigniter.com/user_guide/libraries/pagination.htmlcodeigniter分页定制

在我脑海中,第一件事情就是“CodeIgniter的分页类非常易于使用,它可以动态地或通过存储的首选项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>'; 

而去年第一等,现在在我的设计我做上一页浮动左下一页右浮动,我有一个<div class="middle_pager">它将所有页码保存在中间。

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

谢谢

回答

2

诀窍是,你必须思考开箱即用。

你应该一个一个打开标签在你的“next_tag_open”像

$config['next_tag_open'] = '**</opening tag>**<div>'; 

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

应该做的伎俩添加到末尾的你“prev_tag_close”

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

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

和关闭标签的。

+0

嗯确实是它的超级棒。谢谢 – ant 2010-01-12 18:09:25

1

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

这显然会导致两个对这些页的块元素,打破

好了,所以我今天早些时候有同样的问题,这是真的做我的头,我想出的唯一解决方案(适用prefectly ) 这是;

绕输出创建一个div -

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

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

$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或无论您希望如何预先链接元素。请参阅下面的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; 
+0

欢迎来到堆栈溢出!感谢您填写此答案。 – 2013-01-18 23:16:34