Welcome Guest, Not a member yet? Register   Sign In
Fixed number of links in pagination
#1

[eluser]Constantin Iliescu[/eluser]
Hello!

I want to always have 10 link in pagination. Does anybody have an idea how I could accomplish this? As far as I can see in documentation, only the number of links from left and right of the current page can be set.

Thank you.
#2

[eluser]toopay[/eluser]
[quote author="cili" date="1309880395"]I want to always have 10 link in pagination. [/quote]

Then you need to manage pagination config for 'total_rows' and 'per_page'. Everytime you retrieve data from your database, you can use 'LIMIT' clause to limiting your database result into exact 10 * your 'per_page' config.
#3

[eluser]Constantin Iliescu[/eluser]
Hi, toopay,

Sorry, I haven't been too clear.

I'm trying to find if there's a way to specify the number of links shown at a time, similar to 'num_links' config.

So, instead of telling pagination to display "x" links to the left and right of the current page, can I tell it to always display "y" links?

Thank you.
#4

[eluser]osci[/eluser]
pagination library, as you see uses num_links config. There is no other setting for this behaviour. Either you extend pagination class to have this feature or you convert your 'y' links to num_links like
Code:
$config['num_links'] = (int)(y/2);
If your 'y' is even then it should work as you want otherwise because y % 2 = 1 you would get one link less, so in such a case maybe extending could be your only solution.
#5

[eluser]Constantin Iliescu[/eluser]
Thanks, osci.

The solution was, indeed, to extend the pagination class.




Theme © iAndrew 2016 - Forum software by © MyBB