views:

117

answers:

3

I have CCK and Views module installed. For the sake of this question scope, I'll call the content type as Project. Projects have many Members.

Project nodes are accessible through /project/project-name. I want to be able to display list of members through path /project/project-name/members.

Is there any way to do this?

Currently I have a views setup for page display on path /project/%/members, and have the argument taken from the url. I realize I can't use "Node ID from URL" option directly since it's node name instead of node id. Therefore I tried to enable "PHP Code" argument. But the problem is, Drupal Views always assume that the parameter is "project-name" and therefore ignored my php code argument setting. Anyone knows how I might be able to do this?

Thanks

+1  A: 

If the project's name is the node title you can get what you want pretty easily.

You can pass the node title as argument instead of the nid, but the result will be the same. You get some options to use lowercase, transform - to space ect, as what you can do in a url is limited compared to a node title.

The rest of the view would be the same, as the solution using node nids in the url.

googletorp
Yes it is the node title. Btw, I have successfully setup the views for block display to list members on /projects/project-name because I used pathauto, so I can easily say that argument is taken from Node ID from the URL. Is there any way I could use this views for page display too? In this case, it would restrict me to use node id as argument only. I was looking for a way to somehow transform the argument maybe using some hook or views_pre_build or something to transform the node title to node id.
Ferry
A: 

You need to create path aliases for /project/project-NID/members to /project/project-Name/members

Nikit
How can i create path alias for each node? Do I have to create custom hook on node submit or are there any easier ways to do this?
Ferry
Yes, custom hook on project submit...
Nikit
A: 

I asked this exact question a month ago. :)

http://stackoverflow.com/questions/2079224/drupal-link-to-view-dependent-on-argument

Jourkey
I managed to get it done w/o additional modules using Drupal's custom_url_rewrite_outbound and custom_url_rewrite_inbound.
Ferry

related questions