Joomla web development, eMarketing and training
Home Joomla 1.5 Web Development Tutorials Limit frontpage and blog layout intro text
Joomla 1.5 Web Development
Limit frontpage and blog layout intro text
Sunday, 28 September 2008 17:49

Question: The default Joomla frontpage and blog layouts are nice. But, if the user forgets to add the read more break, the whole article shows up. So, we want to limit the intro text of the front page to 100 characters and the blog layouts to 300. 

Answer:

1) open: \components\com_content\views\frontpage\tmpl\default_item.php
Around line 119 find:

<?php echo $this->item->text; ?>

Replace with:

<?php
$limit =100;
if (strlen($this->item->text) > $limit) {
echo (substr($this->item->text, 0, $limit)) . " ... ";
}
else {
echo $this->item->text;
}
?>

What this does is limit the intro text to 100 characters.  For the blog layouts open \components\com_content\views\category\tmpl\blog_item.php and do the same, but change the value of 100 to 350.  This will show 350 characters vs 100.

 

Add your comment

Your name:
Subject:
Comment:
  The word for verification. Lowercase letters only with no spaces.
Word verification:



+ Suggested tags