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.

CommentFileSizeAuthor
#3 clipper_views.patch.txt864 bytestelex4

Comments

telex4’s picture

Status: Active » Needs work

OK, here's a first stab. I get an odd error, though:

user warning: Unknown table 'relations' in where clause query: SELECT count(DISTINCT(node.nid)) FROM node node LEFT JOIN signup_log signup_log ON node.nid = signup_log.nid WHERE (node.type IN ('content-task')) AND (relations.left_id = node.nid) in /var/www/spreadkde_dev/drupal-cvs/includes/database.mysql.inc on line 120.

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");
}
Bèr Kessels’s picture

can you upload the patch, please?

telex4’s picture

StatusFileSize
new864 bytes

Here you go.

avpaderno’s picture

Issue summary: View changes
Status: Needs work » Closed (outdated)

I am closing this feature request, as it's for a not supported project version. If you want to see this feature implemented for a supported project version, please re-open this issue.