Offer a views filter
telex4 - March 30, 2006 - 00:57
| Project: | Clipper |
| Version: | HEAD |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs work |
Description
Not full integration with views, but one feature I'd dearly like: expose a filter to views that allows admins to filter according to how many parents a node has, or perhaps even just whether or not nodes have a parent.
This would allow me to build a table only with "top-level" nodes for a tasks list.
With a bit of guidance I could probably hack this up myself.

#1
OK, here's a first stab. I get an odd error, though:
Even though I've used ensure_table it doesn't appear in the query. Not too sure what's going on there... here's the code:
function clipper_views_tables() {
$tables['relations'] = array(
"filters" => array(
"left_id" => array(
"name" => "Clipper: Node is a parent",
"operator" => array('is a'),
"list" => array("parent"),
"handler" => "views_handler_filter_children",
"value-type" => "array",
"help" => t("This filter allows you to only show nodes that are clipper parents")
),
),
);
return $tables;
}
function views_handler_filter_children($op, $filter, $filterinfo, &$query) {
$query->ensure_table("relations");
$query->add_where("relations.left_id = node.nid");
}
#2
can you upload the patch, please?
#3
Here you go.