0

I'm running into the problem where I have to join a node and a registration. The nodes are of type 'event' and the registration is available for some, but not all of them.

So basically I have a list of event nodes, and I left join the registrations on them, giving me some extra information where available.

The problem is I want to list only my registrations. So a contextual filter has to be added somewhere. The problem; The default filter applies after the join, filtering also all nodes for which I have not yet registered. But I want to show those.

Therefor I am looking for a custom handler that allows me to add an 'extra' statement to the views join clause. I've looked for it, but started t doubt where such a thing is actually possible. Had anyone ever tried such a thing?

I suppose I need to make a custom hander, it's not a problem. But can handers 'communicate', or is there something like a hybrid handler of some sort?

Wrong query

SELECT ...
FROM 
{node} node
LEFT JOIN {node_registration} node_registration_node ON node.nid = node_registration_node.nid
WHERE (( (node_registration_node.uid = '1' )

Working query, but non contextual

SELECT ...
FROM 
{node} node
LEFT JOIN {node_registration} node_registration_node ON node.nid = node_registration_node.nid AND node_registration_node.uid = '1'
3
  • I would say your question is more of an sql question than a drupal one. There are various modules available for event registration. Have you looked at drupal.org/project/registration Sep 27 '13 at 8:47
  • Yes Andrew, I used that module first. But that was lacking the same functionality. I'm probably looking for a custom argument-handler that can alter or override the relationship-handler. If only I knew if such a thing was possible... Sep 27 '13 at 10:13
  • drupal.stackexchange.com/questions/82165/… this might help Sep 30 '13 at 11:16
0

Thanks for the suggestions Andrew, I ended up creating a custom argument-handler. It adds one (or more) extra conditions to the join. LEFT JOIN ... AND ....

function query($group_by = FALSE) {
  $this->ensure_my_table();

    $this->query->table_queue[$this->table_alias]['join']->extra = array(
      array('table' => $this->table_alias, 'field' => $this->real_field, 'value' => $this->argument),
    );
  }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.