Community Documentation

Increase the number of nodes per page when administering content

Last updated June 17, 2009. Created by Frank Ralf on December 16, 2008.
Edited by bekasu. Log in to edit this page.

Sometimes you might want to see more than the standard 50 nodes per page when you administer content (/admin/content/node/overview). Unfortunately, this number of 50 nodes per page is hardcoded into the Node core module (modules/node/node.admin.inc, line 461).

This mini module adds a select field to the administer content page for selecting a different number of nodes per page and stores this value in the variable table in the database.

Important note:

For this mini module to work you need to modify code from a core function. It's only a slight modification but be sure you know what you do. And in any case read the following instructions beforehand:

Cleanly overriding core modules in Drupal through the magic of multisite
http://raincitystudios.com/blogs-and-pods/boris-mann/cleanly-overriding-...

One way to override Drupal core modules - safely
http://www.elvisblogs.org/drupal/one-way-override-drupal-core-modules-sa...

Overriding core module functions

For an ongoing discussion about this delicate subject see:

Enable override and extension of core module functions
http://drupal.org/node/29428

Modification to node.admin.inc

Here's the modification to the node.admin.inc file. You have to replace the hardcoded 50 in the pager_query() function with a variable ($limit) which calls the variable from the database or sets a default value, if the variable is not set.

<?php
/**
* Form builder: Builds the node administration overview.
*/
function node_admin_nodes() {
 
 
$limit = variable_get('default_nodes_overview', 50); // added for the module
 
 
$filter = node_build_filter_query();

 
$result = pager_query(db_rewrite_sql('SELECT n.*, u.name FROM {node} n '. $filter['join'] .' INNER JOIN {users} u ON n.uid = u.uid '. $filter['where'] .' ORDER BY n.changed DESC'), $limit, 0, NULL, $filter['args']);
...
?>

.module file

<?php
// $Id$

/**
* @file
* Sets the default number of nodes to display per page on the content admin page (/admin/content/node/overview).
*/

/**
* Implements hook_form_alter().
* Adds a select field and a submit button to node_admin_content form.
*/

function default_nodes_overview_form_node_admin_content_alter(&$form, &$form_state) {
 
$form['default_nodes_overview'] = array(
   
'#type' => 'select',
   
'#title' => t('Number of nodes on content admin page'),
   
'#default_value' => variable_get('default_nodes_overview', 50),
   
'#options' => drupal_map_assoc(array(10, 15, 20, 25, 50, 100, 200)),
   
'#description' => t('The default number of nodes to display per page on the content admin page (/admin/content/node/overview).'),
   
'#weight' => 1,
  );

 
$form['submit'] = array(
 
'#type' => 'submit',
 
'#value' => t('Save settings'),
 
'#submit' => array('system_settings_form_submit'),
 
'#weight' => 2,
  );
}
?>

.info file

name = "Default Nodes Overview"
description = "Sets the default number of nodes to display per page on the content admin page (/admin/content/node/overview)."
core = 6.x
package= Core modifications

Comments

Shouldn't this be made into a

Shouldn't this be made into a variable in core?

Cheers

________________
Live fast die young

Doesn't work for Drupal

Doesn't work for Drupal 6.2

$result = pager_query(db_rewrite_sql('SELECT n.*, u.name FROM {node} n '. $filter['join'] .' INNER JOIN {users} u ON n.uid = u.uid '. $filter['where'] .' ORDER BY n.changed DESC'), 50, 0, NULL, $filter['args']);

--
Qasim Zeeshan
http://intellimus.com

About this page

Drupal version
Drupal 6.x

Reference

Drupal’s online documentation is © 2000-2012 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License.