Extend node filters form

I've been wanting to extend the default node_filter_form on admin/content/node since ages so I finally wrote my own patch because I really needed it for some projects. The patches attached introduce a new hook called hook_node_filters. Modules can hook into the default node_filters function to add their own select boxes and types to filter on. An example hook could look like this:

* Implementation of hook_node_filters().
* Returns extra filter option at admin/content/node to filter on every page.
function testmodule_node_filters() {
$q = "SELECT n.nid, n.title FROM {node} n WHERE n.type = 'page'";
$result = db_query(db_rewrite_sql($q));
   while (
$row = db_fetch_object($result)) {
$options[$row->nid] = $row->title;
   return array(
'page' => array(
'title' => 'page',
'options' => $options,
'where' => 'n.nid = %d',
'join' => '')

Although I'm pretty sure this patch is safe, this is not an official patch reviewed by the Drupal community. In the event something might go wrong, don't hold me responsible allright ? ;) Also, take a look at http://drupal.org/project/better_node_admin_content which will hopefully serve as a patch for D7.

nodefilter-drupal5.patch1003 bytes
nodefilter-drupal6.patch825 bytes


Submitted by Jemand on June 2, 2008 - 17:19

Thanks for the patch. It's working pretty well.

I only have problems filtering the created and changed fields in the table {nodes}. It seems that drupal has problems with big numbers...

Submitted by Lara on October 13, 2011 - 03:10

Had to add a filter-by-domain (using Domain Access module) to a 6.x site, and this worked nicely.

You are here