2

I'm using Drupal 7. I want disable link on some node-title.

Like disable ''Link this field to the original piece of content'' in Views.

How can i do this? For example, via template.php?

1 Answer 1

4

The code that makes that happen is in node.tpl.php:

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

So to override it, you just need to re-create node.tpl.php somewhere in your theme's folder, remove the <a> tag surrounding the title, and clear Drupal's caches. Then you won't get links on title for node teasers any more.

If this is too 'all-encompassing' and you just want to do it for a specific content type then as well as copying the original (unchanged) node.tpl.php into your theme's folder, create another one called, for example, node--article.tpl.php (for the article content type), and make the alterations in there instead.

4
  • Now, i must create node--node--20.tpl.php and override your code, right?
    – Karmacoma
    Commented Jul 3, 2012 at 14:38
  • According to the Drupal 7 Theme Hook Suggestions it would be node--20.tpl.php. I think you might be thinking of page--node--20.tpl.php which would be the page template, not the node
    – Clive
    Commented Jul 3, 2012 at 14:40
  • Ok sorry but my node.tpl file is: pastebin.com/tg16M1Uu
    – Karmacoma
    Commented Jul 3, 2012 at 14:40
  • Just replace $title_link with $title, that should sort it
    – Clive
    Commented Jul 3, 2012 at 14:52

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.