| Read More on Your Joomla Frontpage |
|
| Monday, 10 December 2007 | |
|
This is a guest post from Tom Maiaroto of ExpandTheRoom. In this post he explains how to set the "Read More" on your Joomla frontpage to appear after a certain number of characters. This is useful to keep a standard appearance for your articles when you have a large number of people submitting content.
This post grew out of comment that Tom made on our original discussion about the "read more" on Joomla's frontpage.
We welcome other guest posts. Simply login and click "Make a Guest Blog Post" in the right-hand menu.
How to Change the Joomla Code to Control "Read More"
1. The first file to change is components / com_content / content.php.This is what my content.php looks like: (search for this under frontpage() method) // query records
$query = "SELECT a.id, a.title, a.title_alias, a.introtext, a.sectionid, a.state, a.catid, a.created, a.created_by, a.created_by_alias, a.modified, a.modified_by," and simply add the other column in the database for attribs.
$query = "SELECT a.attribs, a.id, a.title, a.title_alias, a.introtext, a.sectionid, a.state, a.catid, a.created, a.created_by, a.created_by_alias, a.modified, a.modified_by,"
// Main data query
$query = "SELECT a.id, a.title, a.title_alias, a.introtext, a.sectionid, a.state, a.catid, a.created, a.created_by, a.created_by_alias, a.modified, a.modified_by ,"
2. Now put into your show() method:
$article_params = new mosParameters( $row->attribs ); This is a brand new line that lets us use the article's params since the $params here are menu item params:
$introtext_word_cap = $article_params->get( 'introtext_count' );
introtext_count is what I called this param, and in the final step of this tutorial we'll create it in the /administrator/components/com_content/content.xml file
3. Now you'll add in the logic to truncate where it goes into displaying the introtext.
if ( $params->get( 'introtext' ) ) {
// NEW - truncate stuff
4. Edit the administrator / components / com_content / content.xml file.An finally, here's that extra parameter in the content.xml file (note a default of 50 can change to whatever):
<param name="introtext_count" type="text" size="20" default="50" label="Intro Text Word Count" description="How many words to display of the intro text." />
About Tom MaiarotoMy name is Tom Maiaroto and I'm a web developer/designer for ExpandTheRoom located in NYC. My personal blog is at www.concepthue.com/blog. I've been working with Joomla! for a few years now as well as other CMS'. I also create my own CMS systems from scratch.
Bookmark
Email This
Comments (9)
![]()
Plugin?
written by Cory Webb, December 10, 2007
Wouldn't it be possible to handle this with a plugin? I hesitate to modify core files unless it is absolutely necessary.
written by Sean Cook, December 10, 2007
Barrie North had some discussion about this as well:
http://www.compassdesigns.net/...-site.html A lot less hacking involved. written by JL, December 19, 2007
Hi, I have been trying to do this but the modifications let me all the front page articles without any text, If I choose -> "Hide intro text" it shows me the introtext with the new parameter (50) but it's a lot of work doing this with each article you know?
Any help? Please P.D: sorry for my bad English written by TomM, December 21, 2007
you want to change the default 50 to something else?
it's in the xml file. then you don't have to go to each article and change 50 to whatever. is this what you were after? written by Kim Knudsen, January 25, 2008
Hi, when trying to modify my website with the above, all my frontpage articles shows up with the following text "you are not authorized to view this ..." or something like that. PLZ. HELP
nimmer written by Kim Knudsen, January 27, 2008
Ok, I managed to fix my first error - I upgraded my joomla to 1.0.13 - I was running 1.0.11. But now I have the same problem as JL above. All my articles shows up with no content on the frontpage. I have to change every article to not show the introtext before it actually shows up. Plz help
nimmer written by Muhammad Noman, March 19, 2008
hi i want "ReadMore" link dynamically i.e in some pages it will appear as "Read More..." and in some pages as "View Details...". How can i do this? any idea? plz help
written by Joao Goncalves, May 23, 2008
I liked the layout of this website.
How can i implement the "Read More" & "Add Comment (x)" like this site has? (The pics too.) How do can do this? Any tutorials/text? Write comment
|


