How do you remove all $links from the teaser except the "read more" link?

Comments

NancyDru’s picture

hook_links_alter or change you theme. There are many posts out here about how to do it.

Nancy W.
Drupal Cookbook (for New Drupallers)
Adding Hidden Design or How To notes in your database

knugar’s picture

By implementing hook_link_alter() whithin a module you can play around with the links.

Z2222’s picture

I'm not sure how to do that. I've seen the hook_link_alter() page but it assumes prior knowledge of information that I don't know where to find...

davesgonebananas’s picture

Here's some code you can drop into a custom module for your site.

// custom is the name of the module
function custom_link_alter(&$node, &$links) {
	// only alter links on teasers
	if ($node->teaser) {
		// step through each link on this node
		foreach($links as $module=>$link) {
			// we let the read more link past, but delete all the others
			if ($module!='node_read_more')	{
				unset($links[$module]);
			}
		}
	}
}
Z2222’s picture

Thanks for the tip, but I'm not sure how to make a module. Is there a way to do it without creating a module?

Right now I'm doing something like:

<?php if ($page) {
  print ($links);
} else {
  print(l('Read More', "node/$node->nid"));
}
?>

But that doesn't work if I want a little more control—like maybe also leaving the link to the author's blog.

Z2222’s picture

Just found the answer here:

http://drupal.org/node/134442

davesgonebananas’s picture

Yep that'll work as well - though not as cleanly as using a module. Just be careful as theme_links is called by menus and all sorts so it would be easy to break the site.

joachim’s picture

As far as I can tell, $node->teaser is set at this point whether the node is being shown as a teaser or in full -- is there a way of distinguishing between teaser and full context?

RobBNL’s picture

Hi All,
I have been reading a lot about modifying the teaser, including the module that changes the location where it is displayed. But I do not want to use that functionality at all. I just want the pages to be displayed fully. No Read more links.
Can someone help me and tell me how to do that?
Rob

sepeck’s picture

This is unrelated to the current conversation.
Look in /admin under the content stuff for post settings.

-Steven Peck
---------
Test site, always start with a test site.
Drupal Best Practices Guide -|- Black Mountain

-Steven Peck
---------
Test site, always start with a test site.
Drupal Best Practices Guide

gisle’s picture

The project Fix teaserlinks may be used to mange the visibility of the links that appear below teasers (i.e. “Add new comment”, “Log in or register to post comments” and “Read more”).

- gisle