Drupal 7 Remove " read more " Link in teaser

webadmin's picture
Coding

I don't need read more link on teaser, then you can place this code below in node.tpl.php. Example above if we use code snippet in theme batrik drupal 7 core. If you are using another themes please refer to your node.tpl.php and locate code render($content['links'] .

node.tpl.php in batrik

<?php
// Remove the "Add new comment" link on the teaser page or if the comment
// form is being displayed on the same page.
if ($teaser || !empty($content['comments']['comment_form'])) {
unset($content['links']['comment']['#links']['comment-add']);
}
// Only display the wrapper div if there are links.
$links = render($content['links']);
if ($links):
?>

<?php print $links; ?>

<?php endif; ?>

Change to custom node.tpl.php on your themes

<?php
// Remove the "Add new comment" link on the teaser page or if the comment
// form is being displayed on the same page.
if ($teaser || !empty($content['comments']['comment_form'])) {
unset($content['links']['comment']['#links']['comment-add']);
}
// Only display the wrapper div if there are links.
// dsm($content['links']); // -> use this if you have devel module installed on your D7 core
unset($content['links']['node']['#links']['node-readmore']);
$links = render($content['links']);
if ($links):
?>

<?php print $links; ?>

<?php endif; ?>

do you see what different ? ok then you go.!
in another case you can put hide() API to hide your variable.. in my corolla themes node.tpl saw like this :

node.tpl.php corolla themes

<?php if (!empty($content['links'])): ?>
<?php print render($content['links']); ?>
<?php endif; ?>

Change to :

<?php if (!empty($content['links'])): ?>
<?php //dsm($content['links']['#links']['node-readmore']); ?>
<?php hide($content['links']['#links']['node-readmore']); ?>
<?php print render($content['links']); ?>
<?php endif; ?>

Baca Juga