Focal55 wants to be your web guy

Drupal 6 Faceted Search increase items per page

February
6

By Joe Ybarra, Lead Developer

Tags:

ALISO VIEJO, Calif. — I am using the Faceted Search module and I needed to adjust the results per page.

Luckily seddonym posted on Drupal my first clue to adjusting the items per page. Since I was using the Teaser display option, the setting is being set on Admin > Content > Post Settings. After going to Admin > Content > Post Settings using the Fire Fox browser, I used the Web Developer plugin to view all the forms fields. Locating the hidden input field with the attribute name="form_id" reveals that the form is called node_configure.

I needed a specific number on my results to closely control the amount of search results per page on the faceted search module for drupal 6. Knowing the form id is node_configure, I utilized the hook_form_alter function in my custom module. For those with little module development experience, its fairly easy to create a new module and enable it from the Admin > Site Building > Modules page. With a custom module you can safely and propertly override elements in your website.

Here is my use of the hook_form_alter function

<?php
function mymodule_form_alter(&$form, $form_state, $form_id) {
if (
$form_id == 'node_configure') {
   
$form['default_nodes_main']['#options'] = array(
       
'1' => t('1'),
       
'2' => t('2'),
       
'3' => t('3'),
       
'4' => t('4'),
       
'5' => t('5'),
       
'6' => t('6'),
       
'7' => t('7'),
       
'8' => t('8'),
       
'9' => t('9'),
       
'10' => t('10'),
       
'15' => t('15'),
       
'20' => t('20'),
       
'25' => t('25'),
       
'30' => t('30'),
       
'100' => t('100'),
    );
}
}
?>

I added the 100 items, option to the select list. Drupal 6 Form API is great to work with. Looking at an example of the select type form element on the Drupal Form API page gave the exact reference to apply my changes.

Add a Comment