Contact Us Sitemap
Main Menu
Learning Greek
- - - - - - -
- - - - - - -
More Articles
- - - - - - -
CafePress Designs
- - - - - - -
Free Downloads
Web Links
Subscribe to RSS
RSS Feed
Who's Online
Visitors: 3310738
Login Form

Lost Password?
Blog Directory & Search engine

Warning: Call-time pass-by-reference has been deprecated in /home/content/m/i/k/mikenoel/html/mambots/content/joscomment.php on line 43
Changing the Joomla! limitbox Print
Written by Mike Noel   
Friday, 30 March 2007
The standard installation of Joomla! statically defines an HTML SELECT statement to control the number of list elements shown per list page. These SELECT statements contain the values 5,10,15,20,25,30, and 50. In some cases a webmaster wants to offer more options to the site viewer. This article explains how to modify the Joomla! core files (version 1.0.12 only) to add more options to this dropdown box.

What are we doing?

In the Joomla! code this "number of entries per page" select box is referred to as the "limit box". This has to do with the way that the value is used when extracting data from the database. For the rest of this article I'll refer to this drop-down box as the limitbox.
There are four different limitboxes that are used on a Joomla! site. One is visible on the public site and the other three are used in the adminstration panel. The public one is used anywhere a limitbox is shown (excepting 3rd party components that do their own). For example, when displaying content categories in a table (or list), the interface will display the limitbox. The three administrator control panel limitboxes are the global default setting for limitboxes, the admininstrator page navigation limitbox, and the limitboxes defined for each menu type parameter section.
The limitbox code is a part of the Joomla! core. That means that in order to make changes to the default limitbox behavior you will have to edit some of the base Joomla! files. This is a somewhat dangerous and risky thing to do. By making these changes you will be causing your Joomla! installation to be non-standard. This might affect interoperability with 3rd party components and might make Joomla! upgrades more difficult. It is up to you to decide if it is worth it to make the changes.
This article assumes that you know how to edit core files (if you don't, then you might not want to be doing it!). It also assume that you have at least a basic knowledge of PHP and text file editing.

The public limitbox

The public limitbox is the one shown for all standard content layouts that show lists of items and include page navigation to skip through those lists. The limitbox usually shows up above the righthand corner of the table holding the list. The elements in this box are controlled by the code in the file homedir/includes/pageNavigation.php. In that file there is a php function called getLimitBox. In that function there is a for loop that looks like this:
  for ($i=5; $i <= 30; $i+=5) {
    $limits[] = mosHTML::makeOption( "$i" );     
This loop creates the entries from 5 to 30. After that there is an explicit mosHTML::makeOption("50"); to add the 50 value. Change this for loop to:
  for ($i=5; $i <= 100; $i+=5) {
    $limits[] = mosHTML::makeOption( "$i" );     
And add additional makeOption lines:
$limits[] = mosHTML::makeOption( "125" );
$limits[] = mosHTML::makeOption( "150" );
$limits[] = mosHTML::makeOption( "200" );
This is all you need to do in order to add more options to the public limitboxes. If that's all you wanted to do you can stop here. The other limitbox settings deal with default values in the administrator and configurations.

The administrator limitbox

When the administrator panel displays list data it also has a limitbox. This limit box is not the same as the public site limitbox but it is defined in the same way. It is defined in the file homedir/administrator/includes/pageNavigation.php. Notice that this is the same location as the public site limitbox code but in the administrator directory.
The changes for this limitbox code are identical to the changes for the public site limitbox.

The administrator default limitbox

In the global configuration screen there is a configuration option to set the "default limitbox value". This is the default value that will be used on all limitboxes (other than menu-based -- see next section). The code to control this is in homedir/administrator/components/com_config/admin.config.php. Look for the lines that look like this:
$listLimit = array(
mosHTML::makeOption( 5, 5 ),
mosHTML::makeOption( 10, 10 ),
mosHTML::makeOption( 15, 15 ),
mosHTML::makeOption( 20, 20 ),
mosHTML::makeOption( 25, 25 ),
mosHTML::makeOption( 30, 30 ),
mosHTML::makeOption( 50, 50 ),
Insert as many additional options as you want.

The menu type limitboxes

Every menu item has a configuration screen where you can set various menu parameters that will affect how the item is shown. This list of parameters, and their possible values, is defined in an xml document for each menu item type. These xml documents are located in homedir/administrator/components/com_menus/type/type.xml. The type corresponds to the menu item's type. For instance, if you created a menu item for a category list, that menu type is content_category and the xml document controlling the parameters is content_category.xml.
In that xml file will be a section for the "display_num". This controls the default value of the limitbox to use when displaying this particular menu item (on the public site). In the XML entry that defines the display_num you can add as many additional options as you like. This only affects what the administrator can set as the default for this item. Editing the XML file can be done for any of the menu types.

All done

After making these changes your site will now display the modified limitbox in both the public areas and the administration areas. For best results all of the limitboxes should be configured to have the same values. It is not clear what will happen if you have mismatches between different limitbox values.
I know that I have skipped over some details in this description but I hope that I have provided enough to get you headed in the right direction. If you know of a better way to do what I'm suggesting here I would be happy to know about it.

Copyright 2004 - 2008 Mike Noel. All rights reserved.
This Site is powered by Joomla!.