J3.x

Difference between revisions of "Add article title to read more link"

From Joomla! Documentation

(One intermediate revision by one other user not shown)
Line 1: Line 1:
{{review}}
+
Some people want to add the article title to the readmore link. To achieve this you can set that on your menu item or in Article management options. By default the menu item settings point to the Article management Options settings by "Use Global".
  
Some people want to add the article title to the readmore link. To achieve this you can use a [[How_to_override_the_output_from_the_Joomla!_core|template override]].
+
Set it on your menu item:
 
+
# Go to Menu management
If they are not already there, in your template folder:
+
# Edit the menu item
# Create a new folder called 'html'.
+
# Go to tab Advanced Options
# In that folder you create a folder called 'com_content'.
+
# Set "Show readmore" to Show
# And in that folder you create the folders called "category", "frontpage" and "article"
+
# Set "Show title with readmore" to Show
 
 
Then locate the following files:
 
*(joomla)/components/com_content/views/category/tmpl/blog_item.php
 
*(joomla)/components/com_content/views/featured/tmpl/default_item.php
 
*(joomla)/components/com_content/views/article/tmpl/default.php
 
 
 
Copy the files to their respective locations in the template's html file:
 
*(yourtemplate)/html/com_content/category/blog_item.php
 
*(yourtemplate)/html/com_content/featured/default_item.php
 
*(yourtemplate)/html/com_content/article/default.php
 
 
 
Open these files. Towards the bottom of each of these files you should see something like:
 
<source lang='php'>
 
<p class="readmore"><a class="btn" href="<?php echo $link; ?>"> <span class="icon-chevron-right"></span>
 
<?php if (!$params->get('access-view')) :
 
echo JText::_('COM_CONTENT_REGISTER_TO_READ_MORE');
 
elseif ($readmore = $this->item->alternative_readmore) :
 
echo $readmore;
 
if ($params->get('show_readmore_title', 0) != 0) :
 
echo JHtml::_('string.truncate', ($this->item->title), $params->get('readmore_limit'));
 
endif;
 
elseif ($params->get('show_readmore_title', 0) == 0) :
 
echo JText::sprintf('COM_CONTENT_READ_MORE_TITLE');
 
else :
 
echo JText::_('COM_CONTENT_READ_MORE');
 
echo JHtml::_('string.truncate', ($this->item->title), $params->get('readmore_limit'));
 
endif; ?>
 
</a></p>
 
</source>
 
 
 
Change the line
 
<source lang='php'>echo JText::sprintf('COM_CONTENT_READ_MORE_TITLE');</source>
 
into
 
<source lang='php'>echo JText::sprintf('COM_CONTENT_READ_MORE_TITLE', $this->item->title);</source>
 
 
 
The “Read more” link should now look like this:
 
'''Read more: (Article title)'''
 
  
 +
Set it on Article management Options:
 +
# Go to Article management Options
 +
# Go to tab Articles
 +
# Set "Show readmore" to Show
 +
# Set "Show title with readmore" to Show
  
 +
No need to set it on the menu items now.
 +
 
<noinclude>[[Category:Tips and tricks]]
 
<noinclude>[[Category:Tips and tricks]]
 
[[Category:Article Management]]
 
[[Category:Article Management]]

Revision as of 19:22, 8 September 2013

Some people want to add the article title to the readmore link. To achieve this you can set that on your menu item or in Article management options. By default the menu item settings point to the Article management Options settings by "Use Global".

Set it on your menu item:

  1. Go to Menu management
  2. Edit the menu item
  3. Go to tab Advanced Options
  4. Set "Show readmore" to Show
  5. Set "Show title with readmore" to Show

Set it on Article management Options:

  1. Go to Article management Options
  2. Go to tab Articles
  3. Set "Show readmore" to Show
  4. Set "Show title with readmore" to Show

No need to set it on the menu items now.