tags:

views:

135

answers:

1

I've used CCK to create a 'Travel Offer' content-type which basically just lists the details for a travel package.

My question is how to have a button or link on each node (when the user views it) that will link to a url that includes the title of the current node (eg: example.com/requestQuote/Title_Of_This_Node).

I haven't implemented my system yet so I am free to change the content-type to include a button field or something like that...

+2  A: 

The easiest way to accomplish this would be by adding a node-your_content_type_name.tpl.php file into your theme folder. (If you haven't done this before, all you need to do is create a duplicate of node.tpl.php and rename the copy to node-your_content_type_name.tpl.php)

The '$title' variable is available within the node template, so it should be easy to craft a little bit of PHP to print out the appropriate link target.

Edit:

Now, if you want to get a little bit fancier, you could build the link to reference the unaliased node page ('example.com/requestQuote/node/11569' or whatever) and feed it through Drupal's handy l() function to build the hyperlink.

The advantage here is that you won't need to worry about the link changing if the title changes, even though l() will automatically update the actual hyperlink that's displayed to the user.

This will probably make the custom coding on your 'example.com/requestQuote' page a lot easier too, since you can work directly with the node ids and don't need to parse titles.

anschauung

related questions