1
votes

I am using Drupal 7 and have created a custom content type and a view that displays those content types. What I want to do is override the url to the node in the teaser view. My specific use case is this:

I have a support view that displays support content types. When I view that page, I see the teasers for the support content types I have created: Safety, FAQ, Ticketing. Safety and FAQ link to their nodes as expected. What I am trying to accomplish, is have the teaser and image for ticketing there, but have it link to my external ticketing portal. Essentially, I would like to have a checkbox when creating content of this type that allows me to link to external url. I do have the link module installed, but there is no way for me to apply that field to the url of the title.

I have spent a while googling around trying to find the answer, but without much success. If there is nothing available to do this already, I wouldn't mind building a module and submitting it to the community. Just want to make sure I'm not missing anything.

Thanks in advance.

UPDATE

Here are the steps I took using the answer given below:

  1. Install the link module: http://drupal.org/project/link
  2. Create a content type, add a field for link
  3. Add new content of that type and add the url you want to link to in the link field
  4. Create a view and filter by that content type
  5. Under format, i'm using format: "grid" with show: "fields"
  6. Add a field for the Content: link field you created FIRST* in the list. Set to Exclude from display and Formatter: URL, as plain text
  7. Add a title field and deselect "Link this field to the original piece of content" click on "rewrite results" and select "rewrite the output of this field". Enter <a href="[field_link_to]">[title]</a> in the text field where [field_link_to] is the name of the link field as described in the "replacement patterns" dropdown below it.
    • If you do not have the link field in your list of fields FIRST, the token will not be available to the fields below it.
    • In your Content Type > Manage Fields > Link (edit) > Wrapper markup, make sure "no markup" is selected
2

2 Answers

1
votes

You can alter the display of the view using the rewrite options. Make sure your display type is set to 'fields'. Then include the fields you want to display; title, teaser, image.

In the field configuration of the title field, choose 'rewrite results'. there you can enter the following <a href="example.com">[title]</a> That should overrule the title.

Also make sure to uncheck 'link the field to it's node'.

UPDATE: You might have to create a second view for this... To prevent editing the other two elements.

0
votes

Step 7 is different in Drupal 7.22

  1. Title "rewrite results" > select "Output this field as a link" > text field under Link path is only "[field_link_to]" (without <a href=...>... etc.)