Views Integration
norio - May 16, 2008 - 07:53
| Project: | Protected node |
| Version: | 5.x-1.2 |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | norio |
| Status: | closed |
Jump to:
Description
I needed to be able to use views to only show un-protected nodes, so I added the following at the end of my protected_nodes.module. No idea how to contribute properly so I'll just post here. Contact me if you need me to do anything else to contribute this patch into your module...
<?php
function protected_node_views_tables() {
$tables["protected_nodes"] = array(
"name" => "protected_nodes",
"join" => array(
"left" => array(
"table" => "node",
"field" => "nid"
),
"right" => array(
"table" => "protected_nodes",
"field" => "nid"
)
),
"filters" => array(
"passwd" => array(
"field" => "passwd",
"name" => t("Protected: Only show nodes that"),
'operator' => array('IS NOT' => t('Are'), 'IS' => t('Are Not')),
'help' => t('Filter in/out nodes protected with passwords.'),
'handler' => 'views_handler_filter_null',
'value' => _protected_node_hidden_form(NULL, t('protected.'))
)
)
);
return $tables;
}
// copied from bio: bio_views.inc
function _protected_node_hidden_form($value, $markup) {
$form['text'] = array (
'#type' => 'markup',
'#value' => $markup,
);
$form['value'] = array (
'#type' => 'value',
'#value' => $value,
);
return $form;
}
?>Great module by the way!

#1
Thanks! I'll check it out soon and if everything is fine, I'll commit it.
#2
Integrated to the latest DRUPAL5 branch.
#3
Automatically closed -- issue fixed for two weeks with no activity.