What would be the Drupal way to create a dynamic URL field on a content type.

Say I have a content type called 'dogs' and so I use that to catalog all the dogs I like on my site. Now I have created a view that lists in two columns 1) all the dogs that I like and 2) a link to search them on google. There are 100s so I would like to make a dynamic url field because I don't want to type in each google search to each record for the dog content type. So:

Title | Search Link

Maltese, http://google.com/#q=Maltese

Beagle, http://google.com/#q=Beagle


What's the best way to encode the field such that it says:

1) Get the title for this node (Maltese), 2) Append it to the string "http://google.com/#q=" 3) Make this my field_dog_search_url

Is this something that can be done in the admin panel or is it better to use a hook. I'd rather use a hook than download and install yet another module just for this one instance, though I'm interested to know if there is a good module that handles this scenario.

2 Answers 2


If it were me I would rewrite the view column.

You could ether do this through a views template, or just rewriting the output of the column. The latter is probably the easiest, though I personally would use the template as it leaves the output to templates.

To rewrite the column, you could just add another title field, in the second field's settings make sure "Link this field to the original piece of content" is turned off, and then under "REWRITE RESULTS" you should be able to rewrite the output of the filed, and using replacement patterns you should be able to turn it into something like a link that says "search google" and pointing to http://google.com/#q=[title]

If you would like to do it through the template via a views template (again, that's the way I personally would do it) this will help get you started with that: https://stackoverflow.com/questions/15498918/how-do-i-manually-theme-views-in-drupal-7


You can do this through the UI. Select the "Rewrite Results" checkbox and "Output this field as a link". Then use replacement patterns to fill in the dynamic part of the URL.

Views Link

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.