Problem Description
When I'm at the first page, the previous
link is not showing up and so do the next
link when I'm at the last page. I set $config['prev_link']='previous'
and $config['next_link']='next'
.
Question
How to always present, using the CodeIgniter pagination class, the Previous and Next links as <p>
tags when they are not in used?
Update
End up Solving it myself. See solution below. Working on v2.1.3
Example: http://www.friv100flash.com/
ci\system\libraries\Pagination.php
before
after (ADD LAST 3 LINE)
Codeigniter Pagination Library pagination.php
}
In Codeigniter controller
IN Codeigniter View :
Jquery :
Extend Codeigniter pagination class by creating a new file:
MY_Pagination.php
and placing it in theapplication/library
folder.Change all variables and classes prefix declarations from
protected
topublic
.Define two public variable in MY_Pagination.php:
$display_prev_link
and$display_next_link
and set it toFALSE
.In the create_links() function, add to the end of the
if ($this->prev_link !== FALSE && $this->cur_page !== 1)
statement anelseif
statement:and another
elseif
statement to the end of theif ($this->next_link !== FALSE && $this->cur_page < $num_pages)
statement:So Now,
By defining
$config['display_prev_link']
and$config['display_prev_link']
equal toTRUE
orFALSE
, you can control the presentation of thePrevious
andNext
links.Here is the complete
application/library/MY_Pagination.php
file:And don't forget to set
$config['$display_prev_link']
and$config['$display_next_link']
set totrue
orfalse
according to your needs.Good Luck!