I am browsing trough the CI documentation particularly http://codeigniter.com/user_guide/libraries/pagi开发者_StackOverflow中文版nation.html .
First thing that was stuck in my mind was "CodeIgniter's Pagination class is very easy to use, and it is 100% customizable, either dynamically or via stored preferences." but there always but something.
My pagination is as following Previous 1 2 3 4 ... n Next
now for each of these I can create opening html tags and closing html tags in my controller.
For ex:
Previous
$config['prev_tag_open'] = '<div class="previous">';
The opening tag for the "previous" link.
$config['prev_tag_close'] = '</div>';
Next
$config['next_tag_open'] = '<div>';
The opening tag for the "next" link.
$config['next_tag_close'] = '</div>';
And for Last first etc. Now in my design I made Previous float left Next float right and I have a <div class="middle_pager">
which holds all page numbers together in the middle.
From what I see in the documentation I don't have a option in CI to put all page numbers in between html tags, I only have option to put each page number inside some tags, maybe there is a way but I missed a point. Anybody can help?
Thank you
The trick is, that you have to think out of the box.
You should add a an opening tag to the end of of your "prev_tag_close"
$config['prev_tag_open'] = '<div class="previous">';
The opening tag for the "previous" link.
$config['prev_tag_close'] = '</div>**<opening tag>**';
and a closing tag at your "next_tag_open" like
$config['next_tag_open'] = '**</opening tag>**<div>';
The opening tag for the "next" link.
$config['next_tag_close'] = '</div>';
that should do the trick.
That hardly resolves the problem, how would you deal with this situation on the first and last page? The next_tag_open/close would not appear on the final page of the pagination and the prev_tag_open/close would not appear on the first page of pagination.
This will obviously cause both of the block elements for these pages to break
Ok so I had this same problem earlier today and it was really doing my head in. The only solution I came up with (works prefectly) is this;
Create a div around the output -
<div class="pagination2">
<?php echo $link; ?>
</div>
Then use the pagination tags provided by the class around use these tags to wrap around the digit tags (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>';
Now jump into css and relatively position the outer block element pagination2, then go and absolutely position the inner block class pagination, center it and then you can use a negative value to push the absolutely positioned nextlink or prevlink elements however you wish. See below for css I used.
.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;
精彩评论