Remove the read more and comment links on nodes

There are two options to remove the read more and comment links on node teasers

In your theme directory

Function goes into template.php in the enabled theme directory.

As it is a theme adjustement, I prefer to disable links in the theme. However, when you're using a default Drupal theme, then instead of hacking core, use hook_node_view_alter(&build) inside a custom module. Or build a subtheme that extends the core theme to override template.php.


/**
 * Override or insert variables into the node template.
 */
function MYTHEME_preprocess_node(&$vars) {
  unset($vars['content']['links']);
}

In a custom module

This function goes into the .module file of your custom module.


/**
 * Implements hook_node_view_alter().
 */
function MYMODULE_node_view_alter(&$build) {
  unset($build['links']);
}

Don't ever use CSS for hiding stuff, other developers won't have a clue where to find this tricky solution.

Comments

1

Very handy tips to handle drupal.

Add new comment

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
By submitting this form, you accept the Mollom privacy policy.