Welcome Guest, Not a member yet? Register   Sign In
pagination class
#1

[eluser]GSV Sleeper Service[/eluser]
Quote:CodeIgniter's Pagination class is very easy to use, and it is 100% customizable
100% eh?, a bold claim....
what if I don't want next and previous links?
is there an easy way to suppress the next and previous links? I only want the page numbers.
#2

[eluser]xwero[/eluser]
GSV Sleeper Service if you quote you better add a link to the source, in this case the CI documentation.

You can not show the next, previous links by leaving the template settings next_link, prev_link empty but this still generates an a tag. I find it strange the class doesn't checks the content of these settings. create_links snippet:
Code:
// Render the "previous" link
        if  ($this->cur_page != 1)
        {
            $i = $uri_page_number - $this->per_page;
            if ($i == 0) $i = '';
            $output .= $this->prev_tag_open.'<a >base_url.$i.'">'.$this->prev_link.'</a>'.$this->prev_tag_close;
        }
With a small change the a tag is not added
Code:
// Render the "previous" link
        if  ($this->cur_page != 1 && ! empty($this->prev_link) )
        {
            $i = $uri_page_number - $this->per_page;
            if ($i == 0) $i = '';
            $output .= $this->prev_tag_open.'<a >base_url.$i.'">'.$this->prev_link.'</a>'.$this->prev_tag_close;
        }
The same goes for next_link, first_link and next_link.

But there are bigger issues with the pagination library for instance displaying the offset in the url instead of the page number.
#3

[eluser]GSV Sleeper Service[/eluser]
The trouble with setting 'next_link' and 'prev_link' to blank is you end up with pointless anchor tags and an annoying blank space in your markup.
I just came to the same conclusion as you while looking at the pagination library. yippee! another extended native library... I'm happy with page numbers in the url for now.
and for future reference - how do I add links to quotes?
#4

[eluser]GSV Sleeper Service[/eluser]
wait - I've just discovered that the pagination class IS putting offsets instead of page numbers in the urls. I was testing with 2 results per page, and a max of 4 results. the docs don't make this clear, in fact they imply that page numbers instead of offsets will be used. time to roll my own I reckon...
#5

[eluser]xwero[/eluser]
Just add a link using the url bbcode tag, i don't think you can do a fancy thing like

[quote=url]quote[/quote]
#6

[eluser]Flemming[/eluser]
I had the same issue. I figured it's useful to leave all the links in for good semantic markup but use css to make them display the way I wanted, so I did this:
Code:
$config['num_links'] = 10;
$config['full_tag_open'] = '<ul>';
$config['full_tag_close'] = '</ul>';
$config['first_tag_open'] = '<li class="hide">';
$config['first_tag_close'] = '</li>';
$config['last_tag_open'] = '<li class="hide">';
$config['last_tag_close'] = '</li>';
$config['next_tag_open'] = '<li class="hide">';
$config['next_tag_close'] = '</li>';
$config['prev_tag_open'] = '<li class="hide">';
$config['prev_tag_close'] = '</li>';
$config['cur_tag_open'] = '<li class="tabOn">';
$config['cur_tag_close'] = '</li>';
$config['num_tag_open'] = '<li class="tabOff">';
$config['num_tag_close'] = '</li>';
I display the whole pagination output inside a div with an id of 'pagination' and use css like
Code:
#pagination ul li.hide { display:none; }
works nicely and perhaps it will help you?
#7

[eluser]GSV Sleeper Service[/eluser]
a fine idea flemming. I've gone ahead and butchered the pagination class though.




Theme © iAndrew 2016 - Forum software by © MyBB