Closed (fixed)
Project:
Views Field View
Version:
6.x-1.0-beta1
Component:
Documentation
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
29 Mar 2012 at 18:46 UTC
Updated:
1 Sep 2012 at 15:41 UTC
I'd like my parent view to be able to receive an argument and pass it through to a child view. Is there a way to do this? Thanks.
Comments
Comment #1
gthing commentedI used the views_php module to add a php field.
In the setup code I used:
$static = $view->args[0];Assuming you have no actual arguments on the view, [0] will be the first argument.
Then in the output code I used:
<?php echo $static; ?>I hid the field from display and removed the label. Seems to be working okay.
Would this be the best way to do it or is there a better way?
Comment #2
scottrigbyUpdating title for clarity.
Comment #3
damiankloip commentedYou should be able to use the magic !1/%1 (etc..) tokens to do this. You may need the dev versions.
Comment #4
dalearyous commented#3
can you clarify? i am having issues using the tokens listed in the replacement patterns.
Comment #5
damiankloip commentedWhat are you trying to get? are you using the dev version?
Comment #6
dalearyous commentedi have tried dev version and the recommended version. both do the same thing.
i am trying to pass two fields into the child view so that the child view shows the correct data. i have been playing around with it and it seems only one field actually works (in my case "Project Name").
i wrote up a question and posted it here: http://drupal.org/node/1732732
since then, i can get it to do what i want except it, for no apparent reason, excludes certain account names.
Comment #7
dalearyous commentedFIXED IT! this may deserve a bug report. there is something odd going on when passing in your contextual filter. to get around it this is what i did:
go to your child view and add a global php field. in the output code area add this: (you will delete this field later, for debug purposes)
find the field you are trying to pass through and essentially get the raw value, in my case it was this:
$data->field_field_project_name_s['0']['raw']['value'];
now, go to your parent view (i am assuming you have contextual fields set already) and add a global php field with this output code with what we just found out:
save it, drag the field to the top of the order (so it can be used in the views field view). open up your views field view and instead of using the tokens they are suggesting, use the one that correlates to the global php field we just created. in my case:
[%php_2]
and boom, the accounts (project names) that weren't matching up at all are all now working perfectly.
i will write a more concise guide with everything i did, including contextual filters and post back here with link.
http://blog.cvrc.virginia.edu/?q=drupal-guides
Comment #8
jamix commented@damiankloip: Thanks, switching to the dev version solved my problem with the magic !1 token not working properly.