How to Control the “Read More” on Joomla’s Frontpage

A simple tip today. This small Joomla code hack is designed to help those of you who have a lot of people submitting content to their site.

 

Everyone writes and submits in their own way, so its easy to end up with some contributors just writing a single line in the "intro" box and others entering their whole article.

 

With this hack, it doesn’t matter. You can cut off all frontpage items with a "Read More…" after 200 words, giving your site a clean, professional look.

 

Inside /components/com_content/content.html.php you need to scroll down to line 520.

 

Simply replace these lines:

 

                // displays Item Text

                echo ampReplace( $row->text );

with these lines:

if( !isset( $_GET[‘id’] ) ){

                    $explded = explode( " ", $row->text, 201 );

                    $explded[200] = ”;

                    //echo implode( " ", $explded );

                    //if( count( $explded )== 201 ) echo ‘&nbsp;&nbsp;<a href=’.$e[‘titleLink’].’">(more…)</a>’;

                    echo ampReplace( implode( " ", $explded ) );

                    if( count( $explded )== 201 ) echo ‘&nbsp;&nbsp;<a href="index.php?option=com_content&task=view&id=’.$row->id.’&Itemid=2">(more…)</a>’;                

                    echo ‘<!– ‘;

                    print_r( $params );

                    print_r( $row );

                    echo ‘–>’;

                }

                else{

                // displays Item Text

                echo ampReplace( $row->text );

 

Want longer or shorter teasers? Simply replace 200 and 201 with the number of words you’d like to see before the "Read More…" sign.

 

Click here to download the file. 

 

Leave a Reply

Your email address will not be published. Required fields are marked *