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
User Rating: / 0
PoorBest 
Joomla 1.5 Web Development - Tutorials

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.

 
Comments (2)
Hides readmore link
2 Monday, 09 February 2009 17:38
???
This works great but also hides read more link. Which should not get hide otherwise how visitor will read full article?

Thanks!!!

-- Serr response
Given that the character limit is pretty short, a READ MORE link is not really needed (At least for us.) Instead, we just make the "Titles" links, which is set via the menu manager.
Nice
1 Saturday, 07 February 2009 09:51
???
Great hack! Why joomla doesn't have that in standard :) ?

Add your comment

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


Request Services
 
First Name
Last Name
E-mail
Phone
Domain
Question
Budget
  

My cart


+ Suggested tags