0

Building a content type "news headlines." I want the title to be the headline and I want that headline to link to a outside URL that has the full story. This node-summary could then appear on the home page and in a view and not link to the node but to the outside story. I can make a link that does that but cannot figure out how to make the title do this.

  • how you're presenting the news headlines? in a view? – Aboodred1 May 19 '13 at 14:19
  • you mean link to external website – Bala May 19 '13 at 14:53
2

What you can do is implementing a preprocess function for the node.tpl.php file, and alter the content of $variables['node_url'], which is the variable the template file uses when rendering the title.

  <?php print render($title_prefix); ?>
  <?php if (!$page): ?>
    <h2<?php print $title_attributes; ?>><a href="<?php print $node_url; ?>"><?php print $title; ?></a></h2>
  <?php endif; ?>
  <?php print render($title_suffix); ?>

You should first verify $variables['page'] is not TRUE, since that means the node is being shown in its own page, which is not what happens, for example, when the node is shown as teaser in the front page or in a view.

0

In your view, in the Fields section, click on the Content: Title field. In the Rewrite Results field-set, check Rewrite the output of this field. There you can override the output of the field with custom text, replacement tokens, etc. You can also Output the field as a link and set the required link path.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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