Have been trying to figure this out all day and am stuck. I did the following ..
1/ Created regular CCK field and added/shared it with child node type, let's call this field A.
2/ For attached view I filtered to child node type, attached to parent node type, set Arguments for Node content settings to token and pasted in raw token for field A, then added Views argument for field A.
At this point there is some useful functionality as it attaches nodes that share the same value for field A in both parent and child nodes. For example if parent has "Value 18" for field A and child has "Value 18" for field A, the attached view returns the node title or whatever of child node.
However what I'm stuck with is that I want to use another multiple select node reference field to manually exclude references from the attached view. For example the attached view might return ..
Value 18
Value 22
Value 98
Value 229
However if parent node reference field has Value 18 and value 98 referenced, well they would be excluded from the attached view ..
Value 22
Value 229
I do believe the problem lies in tokens not getting an array of nids from multiple selections i.e. [field_reference_1-nids]. From my tests I can only get it to exclude the first selected value. Have tried using multiple terms to no avail, I've read also that multiple terms works only with integers however I don't see how a node reference can become an integer. Any ideas how this can be gotten around?
Comments
Comment #1
OnlineWD™ commentedSorry the listed example ought to say
Title 18
Title 22
Title 98
Title 229
Resulting in ..
Title 22
Title 229
As it either returns match with a child node or it does not, and then loads node Title. The values for shared CCK field only determine the existence of a match between parent and child.
Comment #2
sanderc commentedI'm stuck with the same problem. It seems the nid's passed to the view cannot be an array or string with multiple nid's when there are multiple id's referenced from a node reference field?
Lets say I have a 1-to-n relationship: Projects that belong to a presentation. For every presentation I want to make a selection of projects that I store in a node-reference field with the presentation. Therefore I made a node-reference field with node-type presentation, and its name is field_project. Now I can use Views Attach to view projects with the presentation node, by selecting Argument: token. In the 'token' input field I entered the token [field_project-nid] (as given in the list), but this seems to be a single node-id, instead of a parsed list of node id's like 13,14,16 or 13+14+16.
It would be a great help if I can pass multiple nid's to the view used for views attach.
I guess this is a feature request more than a support request.
@OnlineWD: I think the option to exclude the argumented node-id's in the view would be a seperate feature-request?
Comment #3
Crell commentedI'm not sure you'd even want to use views_attach here. #2 sounds more like a case for a view-as-formatter use case, which I believe there is a different module for.
Comment #4
Rob_Feature commentedYup, this is what I'm stuck on as well. As crell says, I'm actually probably mis-using Views to format the content of the node, but the power it offers when you do this is irresistable (it would take a lot of theming and probably some custom db calls otherwise).
I'm basically trying to get views attach to display node reference nodes on a node display, but the token only spits out the first result, not all of them.
Beyond saying "yes, I second this feature request", I'm also wondering what this "views as formatter" module is that Crell refers to...sounds like it could be the trick. Any more info on this?
Comment #5
Crell commentedhttp://drupal.org/project/nodereference_views - This is the one I meant. I've not used it, but it sounds like what you're looking for.
Comment #6
Rob_Feature commentedFor the record, nodereference_views does exactly what we're talking about here. I'm not a huge fan of installing yet another module (not to mention the requirement to have some funky additional views) to handle this when, in theory, views_attach could do this if the token had multiple values. But that being said, it works.
Thanks for pointing us in that direction, Crell. I'd still like to say this issue's feature request would be great, however.
Comment #7
Crell commentedSince it already exists, I'm really not keen on adding more code to this module. There's nothing wrong with lots of small modules that do a focused task. :-)