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