| 1 |
<?php
|
| 2 |
// $Id$
|
| 3 |
/**
|
| 4 |
* @file
|
| 5 |
* Lets you filter node listing pages simply by &type=story,blog to the URL (for example)
|
| 6 |
*/
|
| 7 |
|
| 8 |
/**
|
| 9 |
* Implementation of hook_help().
|
| 10 |
*/
|
| 11 |
function node_type_filter_help($section) {
|
| 12 |
switch ($section) {
|
| 13 |
case 'admin/modules#description':
|
| 14 |
return t('filters node listings by type');
|
| 15 |
}
|
| 16 |
}
|
| 17 |
|
| 18 |
/**
|
| 19 |
* Implementation of hook_db_rewrite_sql().
|
| 20 |
*/
|
| 21 |
function node_type_filter_db_rewrite_sql($query, $primary_table, $primary_field, $args) {
|
| 22 |
if ($primary_field == 'nid') {
|
| 23 |
if ($str_types = $_REQUEST['type']) {
|
| 24 |
$types = explode(',', $str_types);
|
| 25 |
foreach ($types as $type) {
|
| 26 |
$ctypes[] = db_escape_string($type);
|
| 27 |
}
|
| 28 |
$return['where'] = 'n.type IN (\'' . implode("','", $ctypes). '\')';
|
| 29 |
return $return;
|
| 30 |
}
|
| 31 |
}
|
| 32 |
}
|
| 33 |
|
| 34 |
?>
|