I have defined a viewfield in a content type, and now I have a view providing a list of those content types, e.g.:

CT1
ct1.1
ct1.2
CT2
ct2.1
ct2.2
ct2.3

Now I'd like to be able to further filter the sub-items from the view level, but I can't figure out how to pass an argument into the view for each (the view has arguments that do the filtering already). There don't seem to be any tokens that would pass arguments from the URL (besides which, I can't get the tokens to work).

Any suggestions?

Thanks.

Comments

break9’s picture

I solved this problem using nodehierarchy, viewreference and views 2. I created the hierarchical structure using different conetent types and nodehierarchy then I used the viewreference field in each of the content type so that I could see the children all the way down as if it were a foreach loop to keep the structure correct. I used the same view in the viewreference field for each content type (but you don't have to) then I make sure the defaul settings for the viewreference field are set to the view I need so I don't have to mess with it when I create the node. You must also allow delimited args to be passed to the viewreference field (if you don't check this in the fields admin settings then there won't be an option to add the arg when you create the node). Now when you create the new childe of whatever using nodeheirarchy I set the viewreference default arg field to be the NID once it is saved (so you create, save, then go back in and add the NID to the arg field). then any children subsequently created will be called by the viewreference field. Now all thats left is Views2 now that you have all of your nodes in a hierarchical order and the nodes have viewreference fields you can display them however you see fit. It took me a while to wrap my head around this so if you read it and it doesn't make any sense, that is probably because I am terrible at explaining it.

****Now about tokens I absultely think the viewreference should use tokens so that you don't have to manually enter the NID in the arg field each time a new node is created

I realize this post is for viewfield but after trying many different combination of modules. the above solution was the one that worked for me.

colin_young’s picture

Thanks. I'll check that out. It looks like it might help, but I think the problem is that when the parents (using node reference from CCK) are being displayed in a view, I don't have access to the normal IDs.

e.g. when I tried to embed a view using just views 2 and PHP, I had some code to get the NID and pass that as an argument to the view, and that worked, but only when I was viewing the node. As soon as the parent node is in a view, I don't have access to the NID. What I need is some code that will give me access to fields in the parent. If I could get that, I'd be all set (although it's beginning to look like I can't do it with viewfield).

I had been hoping that maybe viewfield would take any arguments from the url and just pass those along to the referenced view, but that doesn't appear to be the case, and as I said there don't appear to be any tokens that deal with url arguments, not that the tokens are working for me).

I'll give your suggestions a try tonight.

UPDATE: Looks like a good module. I'm still sorting out exactly how to get the arguments passed in (documentation would help), but I think I'll move this discussion over to that forum.

colin_young’s picture

So I am able to get tokens working. One of my problems was that I was originally trying to use tokens representing content fields from the view (i.e. not fields that were present in the node hosting the view). I'm pretty sure I had tried nid previously, but I must have made some typo because nid is working now.

Now I just need to figure out how to pull args from the url and I'll be all set. Off to investigate the token module now...

colin_young’s picture

Status: Active » Fixed

See http://drupal.org/node/273893 for discussion of arg0 ... argn and token module.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.