I want an user configurable boolean view filter, displaying child nodes in an hierarchy based on a value, canDisplayOthers, in the master node. The master/children are joined by a field setID.
I tried to do a self-join, adding a view relationship based on setID, but setID is not in the list of relationship fields.
Using Php, the recipe in:
https://ohthehugemanatee.org/blog/2013/12/26/44497-people-are-wrong-how-to-never-use-views-php/
says to use a handler. My handler would return a boolean, something like:
class mymodule_handler_field_isDisplayable extends views_handler_field {
/**
* Render the name field.
*/
public function render($values) {
$value = $this->get_value($values);
/*
How can I get current node ID (nid) here?
*/
}
}
and a hook_views_data something like:
function mymodule_views_data() {
// Basic table information.
$data['mymodule_ToDisplay'] = array(
'table' => array(
'group' => t('Global'),
'base' => array(
'title' => t('ToDisplay')
),
),
'name' => array(
'title' => t('ToDisplay'),
'field' => array(
'handler' => 'mymodule_handler_field_isDisplayable',
)
),
'filter' => array(
'handler' => 'views_handler_filter_boolean',
)
);
return $data;
}
I can't figure out:
- in mymodule_views_data, what is this thing called 'table'?
- how do I get the setID or current nodeID into the mymodule_handler_field_isDisplayable function?
In curiosity; - what is the minimal hook_views_data? - Where is a good place to find where hook_views* parameters are explained?
I am using drupal7 and views 3
ADDITION 15 July 2014
Geoff, below, kindly mentioned that the problem would be easier if I created a master node content type. I created a masterNodeType content type, containing the fields:
- setID
- canDisplay
Now, masterNodeType and childNodeType have the common field, setID, but I can't see setID when I configure the view relationship. How do I get setID, and/or masterNodeType into the view relationship? What is the criteria for those view relationship components?