Remove $links from teasers (except 'read more')

guitarmiami - August 7, 2007 - 20:37

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

hook_links_alter

NancyDru - August 7, 2007 - 21:18

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

hook_link_alter()

knugar - August 7, 2007 - 21:25

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

$links

guitarmiami - August 7, 2007 - 21:32

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...

Here's some code you can

davesgonebananas - August 7, 2007 - 22:23

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

<?php
// 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]);
            }
        }
    }
}
?>

$links

guitarmiami - August 7, 2007 - 22:29

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.

Docs

guitarmiami - August 7, 2007 - 22:58

Just found the answer here:

http://drupal.org/node/134442

Yep that'll work as well -

davesgonebananas - August 7, 2007 - 23:51

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.

As far as I can tell,

joachim - January 4, 2008 - 16:49

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?

Remove te Read More link completely

RobBastiaansen - September 4, 2007 - 05:05

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

you should start a new post

sepeck - September 4, 2007 - 05:21

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

 
 

Drupal is a registered trademark of Dries Buytaert.