Community & Support

Want help with "Styling node teaser differently in drupal?

Hi.

I am new drupal and currently struggling to setup my new site using it. I am going to use litejazz theme on it. Now, I want to style node teaser differently than full node pages. I don't know php or css so I am facing problems in it. I have the two things.

1) One is the default node.tpl.php whose code is:

<div class="node<?php if ($sticky) { print " sticky"; } ?><?php if (!$status) { print " node-unpublished"; } ?>">
  <?php if ($picture) { print $picture; }?>

  <?php if ($page == 0) { ?>
    <?php if ($title) { ?>
      <h2 class="title"><a href="<?php print $node_url?>"><?php print $title?></a></h2>
    <?php }; ?>
  <?php }; ?>

  <?php if ($submitted) { ?>
    <span class="submitted"><?php print $submitted?></span>
  <?php }; ?>

  <?php if ($terms) { ?>
    <span class="taxonomy"><?php print $terms?></span>
  <?php }; ?>

  <div class="content"><?php print $content?></div>
  <div class="clear-block clear"></div>

  <?php if ($links): ?>
    <div class="links">&raquo; <?php print $links; ?></div>
  <?php endif; ?>

</div>

2) The other is the code with wich I can style node teaser differently.

<?php
if ($teaser) { // node is being displayed as a teaser
// Anything here will show up when the teaser of the post is viewed in your taxonomies or front page
} else { //all other cases
//Anything here will show up when viewing your post at any other time, e.g. previews
}
?>

Now the problem is how can I merge the two codes. I want to remove the $links from node teasers.

Can anyone help me?

Thanks in advance
DIMSKK

Comments

$page

I'm not too familiar with PHP myself, but try this in the node.tpl.php file in place of the part that begins to show the links.

<?php if ($page && $links) : ?>
  <div class="links"><?php print $links; ?></div>
<?php endif; ?>

A node is either a $teaser or it's a $page as far as Drupal themes are concerned. I'm assuming you want the links to show on the full page view of the node, just not the teaser. So logically that would be: if there's information ready to be displayed as a page, and there are links to go with it, show the links. Otherwise, don't do anything.

Thank you very much!

Hi liquid06!

Thanks for the solution. It worked without any problem.

nobody click here