Hi,
I have configured a view with three page displays, each to list persons belonging to a particular office within an organisation. Some persons - those belonging to more than one office - are wrongly listed multiple times in the displays. Here is a (simplified) example:
I have a vocabulary "Organisation" with two levels, like:
Board (tid 1, weight 10)
- Chairman (tid 10, weight 0)
- Member (tid 5, weight 1)
Management (tid 2, weight 11)
- CEO (tid 15, weight 0)
- Manager (tid 20, weight 1)
Some nodes of content type "person" are related to terms under both parent terms, i.e. "Watson" (node 100) has terms "Chairman" (10) and "Manager" (20) attached.
In the display "Board" I have configured a filter Has taxonomy terms (with depth) and selected the parent term "Board" with a depth of 1. Node 100 gets listed twice in the display, although I would expect it to only appear once (as child of term "Board"):
Watson, Chairman
Watson, Manager
(I have also tried to use the filter criterion Has taxonomy term (without depth) with just the child terms selected, but I get the same result.)
Can someone help, please?
P.S.: I also need to sort the nodes by term weight, so that the "Chairman" is listed before the "Member", regardless of language. Is this possible? A patch for 7.x-3.x-dev seems to have been provided a while back - any update on this?
The Query (The term reference field in content type person is called "field_member"):
SELECT node.nid AS nid, field_data_field_member.delta AS field_data_field_member_delta, field_data_field_member.language AS field_data_field_member_language, field_data_field_member.bundle AS field_data_field_member_bundle, field_data_field_member.field_member_tid AS field_data_field_member_field_member_tid, node.title AS node_title, node.language AS node_language, 'node' AS field_data_field_member_node_entity_type, 'node' AS field_data_field_first_name_node_entity_type
FROM
{node} node
LEFT JOIN {field_data_field_member} field_data_field_member ON node.nid = field_data_field_member.entity_id AND (field_data_field_member.entity_type = 'node' AND field_data_field_member.deleted = '0')
WHERE (( (node.status = '1') AND (node.type IN ('person')) AND (node.language IN ('de', 'und')) AND (node.nid IN (SELECT tn.nid AS nid
FROM
{taxonomy_index} tn
LEFT OUTER JOIN {taxonomy_term_hierarchy} th ON th.tid = tn.tid
LEFT OUTER JOIN {taxonomy_term_hierarchy} th1 ON th.parent = th1.tid
WHERE ( (tn.tid = '11') OR (th1.tid = '11') ))) ))
ORDER BY field_data_field_member_field_member_tid ASC, node_title ASC
LIMIT 100 OFFSET 0
| Comment | File | Size | Author |
|---|---|---|---|
| filter_settings.png | 78.3 KB | futurist | |
| filter_configuration.png | 90.16 KB | futurist |
Comments
Comment #1
merlinofchaos commentedYour expectation is incorrect. When a node is attached to multiple terms, then the node will be repeated for each term. YOu can attempt to use the DISTINCT flag, but that doesn't always work because SQL just sometimes doesn't do it.
Comment #2
futurist commentedThanks for clarifying, but I'm having trouble to imagine why this should work the way it does.
Since it is quite common for a node to be attached to multiple terms (from the same vocabulary) I can't see a use case where it makes sense to list the same node multiple times. Also, the configuration UI for "Has taxonomy terms (with depth)" suggests that the filter only lists nodes that have terms under the selected parent term.
Btw: I did try the DISTINCT flag without success. The only alternatives I see are creating separate vocabularies (instead of one hierarchical one) or to create the list as static HTML :( This seems somewhat related.
Comment #3
dawehnerJust to clarify, it's not that views doesn't want you to do it, it's just not technical possible.
If you join to a table then you get all rows provided by the join back.
So you either removed the order by or keep it and live with it.