Forums

Can I remove the "All" option on Pagination dropdown?

benblee 04 Jan, 2009
I've got everything installed and added the patches to set the default list size instead of all. Everything is working great, but my database table is pretty big and exceeds the memory allotted when it displays all...it's almost 15,000 rows right now and growing. I plan on adding other search functions later, I just have to learn an little (or a lot) more php.

Is it possible to remove the "All" option in the pagination dropdown so users don't run into this problem?

If the exceeding memory thing sounds weird, the error that shows up leads to a line in rokbox code in the system directory. I can't figure that one out, but there really isn't any reason for people to view 15,000 records on one page, so I figured this was the best solution.
benblee 04 Jan, 2009
I've already done that part and everything is working fine there. The problem is when you use the dropdown and choose "All", they you get this error:
Fatal error: Out of memory (allocated 35389440) (tried to allocate 7497389 bytes) in /home/starcres/public_html/plugins/system/rokbox.php on line 81


Here's the link:
http://starcrestawards.com/awards/databases/scr

If you choose "All" and get that error, just clear your browsers cache and cookies to revisit it and see it at the default of 25 again.
benblee 05 Jan, 2009
Here's a screenshot of the dropdown I'm talking about:
GreyHead 05 Jan, 2009
Hi benblee,

I tooka look at the code and this is hard-coded deep in the core code (line 329 of libraries/joomla/html/pagination.php). While you could hack that I think that maybe a better solution is to add some JavaScript to your page either to remove that option from your list (the option has a value of '0') or replace it with some smaller default - maybe '200'.

Bob
benblee 05 Jan, 2009
Thanks for the reply. No wonder I couldn't find it.

I'm definitely not an expert at java, is there code that you could suggest or would this require a good bit of work?

I'm not sure how to override something that is being called in from another file.
Once I get this up and running, I am planning on writing up a little tutorial of how I made my form and linked everything together...including how to set up a page for admins to go with backup links for the db tables. It's really just going to be a compilation of a lot of stuff you guys have here, just a "front to back" sort of layout for it.

Thanks again for the great component! It does take learning some code, but what you can do with it is so far beyond anything else out there, it's amazing. Very good marks on the engineering side of things here.
GreyHead 05 Jan, 2009
Hi Ben,

Here's a JavaScript snippet that seems to do the trick
<script type="text/javascript">
window.addEvent('domready', function() {
	var limit_select = $('limit').options;
	if ( !limit_select ) return;
	for ( var i = 0; i < limit_select.length; i++ ) {
        if ( limit_select[i].value == 0 ) {
        	limit_select[i].value = 200;
        	limit_select[i].innerHTML = '200';
        }
	}
});
</script>
It looks for the value='0' option and resets it to 200, you can change the value in the two lines if you like.

Insert this code somewhere on the page.

Bob
benblee 05 Jan, 2009
Works great! Thanks a ton!
bayzin 30 Mar, 2009
hello !
I just want to know how you write that kind of pagination in joomla ?
benblee 30 Mar, 2009
I think it's just taking advantage of the built in pagination function that Joomla already has. You could search the core Joomla files for their code.
bayzin 30 Mar, 2009
thanks for your reply. i mean i already write to list item and i want to add pagination in list. can u suggest me please ?
bayzin 03 Apr, 2009
Thanks benblee,
It's working now, thank for your tutorial.
This topic is locked and no more replies can be posted.