Is there a special way to limit the amount of characters in the teasers title and follow it with a "..." ?

So "I took a long walk in the park today" is shortened to "I took a long..." If the title length is 13.

I've done an extensive search on the topic but the only results showing up are for Drupal 6.

Comments

robotisaurus’s picture

Adding

<?php if ( ($teaser) && ($is_front) ) : ?>
     <h3 class="nodeTitle">
        <a href="<?php print $node_url; ?>">
              <?php $s=strlen($title);
                        if($s>15): ?>
                 <?php print substr($title,0,15)."...";?>
                 <?php else:?>
                 <?php print $title; ?>
               <?php endif?>
        </a>
     </h3>
<?php endif;?>

under

<div class="<?php print $classes; ?>">

section of code and removing

<?php if (!$page): ?>
      <h3<?php print $title_attributes; ?>><a href="<?php print $node_url; ?>"><?php print $title;?>a></h3>
    <?php endif; ?>

in the node.tpl.php file.

Did the trick.

If anyone knows a cleaner way of doing it please let me know.

pasqualle’s picture

Category: feature » support
Status: Active » Closed (fixed)