I have two related column blocks, both generated dynamically by Views. One block displays sibling nodes, all of which share the same parent node. Another block shows nodes that are similar, as determined by their sharing a number of tags. This second block must exclude all of the nodes that also share the same parent, so as to avoid displaying redundant content. This exclusion is working, but it also seems to be removing all nodes that have no parent at all.
For instance, I have a parent node 'Fruit', with children nodes 'apple,' 'orange,' and 'banana.' On the node page for 'apple,' I see that 'orange' and 'banana' are related. I add another parent node 'Vegetables,' with children 'carrots' and 'broccoli.' I now add a node 'bran muffin' that doesn't have any parent. I give the tag 'healthy' to all of the nodes I've added so far. Now, on the 'apple' node, I see 'orange' and 'banana' listed in my siblings block, and I see 'carrots' and 'broccoli' in my related block, but I don't see 'bran muffin' anywhere. On the 'bran muffin' page, I see all of the children of 'Fruit' and 'Vegetables'.
The related view block that I'm having problems with is set up to provide this default when no argument is present (with the exclude argument box checked below):
$node = node_load(arg(1));
if (!empty($node->field_event_parent_cat)){
return($node->field_event_parent_cat['und']['0']['nid']);
}
else {return;}
I can get the functionality I'm looking for by assigning an arbitrary parent to 'bran muffin,' - doesn't matter which, if it has any parent (that wouldn't be excluded on the given page), it now shows up.
Unless I'm missing something in my code, I seems like the exclude option is excluding those cases where the field 'field_event_parent_cat' is empty for a particular node before it evaluates whether the argument has been satisfied.
The relevant portion of the SQL query in live preview:
WHERE (( (node.status = '1') AND (field_data_field_event_audience.field_event_audience_tid = '19') AND (field_data_field_event_parent_cat.field_event_parent_cat_nid != '18') )
It looks like this query is excluding 'bran muffin' because it has no entry at all the in the field_data_field_event_parent_cat table. I don't know SQL syntax well enough to suggest a replacement, but shouldn't the exclusion rule test to make sure that the argument doesn't equal a given value OR that the value isn't set at all for a given node?
Any thoughts?
Thanks,
yskel
Comments
Comment #1
dawehnerOne thing you could do is to use a relationship here.
If you have a relationship for the parent_cat_nid you can use node:nid with this relationship.
Then you don't have this kind of table problems.
Comment #2
dawehnerDoes #1 help you?
Comment #3
yskel commentedSorry for the late reply, dereine. I just upgraded views to beta3 to test, but then I encountered this problem: #1128904: All Style Settings on all views lost in upgrade from 7.x-3.0-alpha1 to 7.x-1.0-beta3. I'll work through this argument issue as soon as I resolve the other.
Comment #4
dawehnerThanks for the spam.
We really appreciate to get two emails which points to the same issue.
Comment #5
esmerel commented