views:

20

answers:

1
+2  Q: 

Dynamic filters

I am setting up a gallery block in views that I am including on different nodes. The main nodes are related to different girls, who I have created as users with custom roles, and each of these girls has a number of photos, each photo brought in as its own node, associated with them. In order to associate the photo with the girl I created a cck field in the photo node with a drop down containing the girls names. So in the photo node type I upload the photo, choose the girl it's associated with and I am done. In the main node type I reused the same cck field so I can put in content, associate the main node with the girl and I am done. I then set up a gallery block in Views to show a gallery of all photo nodes associated with a certain Girl.

What worked was that I created a different block gallery view for each girl and set the filter to her specific name. I then configured each block, via php, to only show in the page that has the corresponding cck field matching the girl's name that is hardcoded into the view filter.

What I would like to do is create only 1 gallery view, it would filter the photo nodes based on the main node's girl cck field. For example all main nodes associated with Suzy, Suzy goes to the beach, Suzy goes shopping, etc. would have the girl cck field set to "Suzy" so the gallery block would only pull in photo nodes that had their girl cck field set to "Suzy". I have tried doing this through Arguments, but it is not working, should I be setting this up through Relationships instead? Or am I missing something basic here?

A: 

If I understand you question correctly, all you would need to do is in the view, create an argument that is set to take the current node id on the appropriate cck node reference field.

That is, the CCK field that you have setup with the girls names should be a node reference field and not just a text field. Have the node reference field point to the content type that you have the girls pages setup to.

Once that is set, in your view add an argument and set it to the node reference field that you added to your various content types. Have it's default argument set to the current nodes id.

Hope this helps!

mattmcmanus