[How to] Add an article title to the Read more... link

How can you add an article title to the “Read more...” link?

Ok, so you'd like something fancier than "Read More" - not exactly very descriptive is it? Using template overrides you can achieve a better looking "Read More" link . 

If they are not already there, in your template folder: create a new folder called 'html' in your template folder /templates/<yourtemplate> In that folder you create a folder called 'com_content' and in that folder you create the folders called "category", "frontpage", "section"

Find the following files 

  • (joomla)/components/com_content/views/category/tmpl/blog_item.php
  • (joomla)/components/com_content/views/frontpage/tmpl/default_item.php
  • (joomla)/components/com_content/views/section/tmpl/blog_item.php

 Copy the files to your template's html folders 

  • (yourtemplate)/html/com_content/category/blog_item.php
  • (yourtemplate)/html/com_content/frontpage/default_item.php
  • (yourtemplate)/html/com_content/section/blog_item.php


Open these files using a text editor:

Nearly at the bottom of these files you should be seeing something like:

<a href="<?php echo $this->item->readmore_link; ?>" class="readon<?php echo $this->item->params->get('pageclass_sfx'); ?>">
<?php if ($this->item->readmore_register) :
echo JText::_('Register to read more...');
elseif ($readmore = $this->item->params->get('readmore')) :
echo $readmore;
else :
echo JText::sprintf('Read more...');
endif; ?></a> 

Change the line

echo JText::sprintf('Read more...'); 

into

echo JText::sprintf('Read more', $this->item->title); 

 And there you have it ... you have a nice edit without actually hacking your core code. This edit will survive a Joomla upgrade :) 

One more thing...

Do you have friends or a Facebook group who you think would find this useful? Share this with them and then let me know what they think.

Want to supercharge your website?

 
Our website loads FAST ... just 1.29 seconds. We're hosted on FAST InMotion VPS servers We want YOUR website to be fast too, so we've gotten you an exclusive deal - 47% OFF for DART Creations friends + FREE domain! Check it out NOW!