Pagination first link with suffix - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Pagination first link with suffix (/showthread.php?tid=48263) |
Pagination first link with suffix - El Forum - 01-10-2012 [eluser]Angilo[/eluser] Hi, the first link in pagination is not giving the right URL when you are using suffix. For SEO purpose you want a link of this type: "/products/overview/30/Watches/Men" products = controller overview = function 30 = pagination Watches = filter on the page Men = filter on the page But since it is a filter, it's not always used. When you do use the filter, and you are not on the first page, the URL to the first page is wrong. The url will be "/products/overview" What you want is "/products/overview/0/Watches/Men" Why? Because else the users' filter will reset. What to change? Remove line 199 in system/libraries/pagination.php Line 199: Code: $first_url = ($this->first_url == '') ? $this->base_url : $this->first_url; Add this to line 195: Code: $first_url = $this->base_url.$this->prefix.(0 * $this->per_page).$this->suffix; This will fix it. It will also fix the URL when you click at "1" or "<". Pagination first link with suffix - El Forum - 04-09-2012 [eluser]Jeroen van Meerendonk[/eluser] Hi there, Thanks for the tip, that's what I was looking for. But that didn't worked until I made a change: Instead: Code: $first_url = $this->base_url.$this->prefix.(0 * $this->per_page).$this->suffix; I added "$this->": Code: $this->first_url = $this->base_url.$this->prefix.(0 * $this->per_page).$this->suffix; I haven't fully tested it but with this change seems to work. Pagination first link with suffix - El Forum - 04-09-2012 [eluser]InsiteFX[/eluser] I hope you are extending the Pagination Library and not modifying it! Pagination first link with suffix - El Forum - 04-26-2012 [eluser]Unknown[/eluser] [quote author="Jeroen van Meerendonk" date="1333968097"]Hi there, Thanks for the tip, that's what I was looking for. But that didn't worked until I made a change: Instead: Code: $first_url = $this->base_url.$this->prefix.(0 * $this->per_page).$this->suffix; I added "$this->": Code: $this->first_url = $this->base_url.$this->prefix.(0 * $this->per_page).$this->suffix; I haven't fully tested it but with this change seems to work.[/quote] I also changed Code: $first_url to $this->first_url on line 200, that makes the "first page" link works Pagination first link with suffix - El Forum - 05-29-2012 [eluser]Unknown[/eluser] Hey, you can have the first page include GET params without hacking by using the first_url config setting. Code: $config['first_url'] = $config['base_url'].$config['suffix']; Example: Code: $config['base_url'] = 'http://mysite.com/controller/index'; I don't know if there's any documentation on this. I found it by looking through source code. |