Title: CodeIgniter pagintation - appending the page number to "page" string
Tags: codeigniter;pagination
Question: What I am trying to achieve is urls outputting via pagination like this:
http://www.mysite.com/users/page5
http://www.mysite.com/users/page-5
At present, it will be using the URI segments like this:
http://www.mysite.com/users/page/5
I can modify the routes.php config file to route the path if the first two URLs are used. So, that's not the issue.
What I am having trouble with is, how do I initialize the settings for the pagination, so that the $this-&gt;pagination-&gt;create_links() will create a pagination with items having links like in the first or the second format?
Let me know if you need more explanation or examples regarding this. I'm not much good in explaining things. :)
Thank you

Here is the accepted answer: This functionality already exists in the in-development version of CodeIgniter 3.0. You can view the Pagination class as it sits here.
To use this library, you can either A) use all of CI 3.0 (it's pretty stable), or B) extend (or, more realistically, replace) the Pagination library by creating application/libraries/MY_Pagination.php and filling it with the contents of the link above. (Full disclosure: it's been a while since I tinkered with CI, so I don't know if anything has changed since that may result in errors with any of this answer.)
To use the feature you want, specify your base URL minus the page-X segment, set that you want to use page numbers instead of offset in your URI segment, and then specify a prefix.
$config['base_url'] = site_url('users');
$config['use_page_numbers'] = true;
$config['prefix'] = 'page-';
Make sure to include your other obvious items as well, such as per_page, etc.
Comment for this answer: Thanks. I tried to extend it. But there was some error saying `access level should be of public for the $base_url`. So, tried replacing the `Pagination.php` file in System folder with this one. It seems to be working now. :)

Here is another answer: To change the functionality of the Pagination library, you can extend the library and override the create_links() function.
Create a file named MY_Pagination.php in application/libraries/
The file should have the following structure, so you can change or add additional functionality to CI's native Pagination library. (It is bad practice to directly change the Pagination library in the system directory.
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class MY_Pagination extends CI_Pagination {
public function __construct()
parent75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0__construct();
You'll then need to add the create_links() function to your MY_Pagination class, allowing you to override its default functionality. Below is an explanation of what you could change to achieve your desired output (you may want to add flexibility, by adding a parameter to the function, but this is the simplest change that I could think of.)
function create_links()
// You can copy the exact functionality of this function from:
// system/libraries/Pagination.php
// The line you want to change is:
// $this-&gt;base_url = rtrim($this-&gt;base_url, '/') .'/';
// Changing to this: $this-&gt;base_url = rtrim($this-&gt;base_url, '/') .'';
// Will create links in this format: ../page5
// Or changing to this: $this-&gt;base_url = rtrim($this-&gt;base_url, '/') .'-';
// Will create links in this format: ../page-5
Comment for this answer: Thanks. I think we need to tweak the determining of current page number in that code too!

{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 2, 'CommentCount': 0, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2013:00:12/27/13', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<codeigniter><pagination>', 'Title': 'CodeIgniter pagintation - appending the page number to "page" string', 'ViewCount': 382, 'id': 20804320, 'user_AboutMe': "<p>I'm from Kerala(Trivandrum City) and I love programming. :)</p>\n<p>Right now, am focusing mainly on Web Development.</p>\n<p>And, am playing with the following technologies/tools:</p>\n<ul>\n<li>PHP</li>\n<li>MySQL</li>\n<li>jQuery</li>\n<li>Wordpress</li>\n<li>Bootstrap</li>\n<li>Codeigniter</li>\n<li>Photoshop</li>\n<li>HTML5 &amp; CSS3</li>\n</ul>\n<p>Want to hire me? Message me in Skype ( <strong>akhileshbc</strong> )</p>\n", 'user_AccountId': 902742.0, 'user_DisplayName': 'Akhilesh B Chandran', 'user_Reputation': 6341.0, 'user_Views': 759.0, 'user_id': 938436.0}}