Add article title to read more link: Difference between revisions
From Joomla! Documentation
Create page. See discussion for review tag |
m M-b-o moved page J2.5:Add article title to read more link to Archived:Add article title to read more link |
||
| (5 intermediate revisions by 3 users not shown) | |||
| Line 1: | Line 1: | ||
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]]. | 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]]. | ||
| Line 5: | Line 5: | ||
If they are not already there, in your template folder: | If they are not already there, in your template folder: | ||
# Create a new folder called 'html'. | # Create a new folder called 'html'. | ||
# In that folder | # In that folder, create a folder called 'com_content'. | ||
# And in that folder | # And in that folder, create three folders called "category", "frontpage" and "article" | ||
Then locate the following files: | Then locate the following files: | ||
Latest revision as of 22:04, 26 April 2022
Some people want to add the article title to the readmore link. To achieve this you can use a template override.
If they are not already there, in your template folder:
- Create a new folder called 'html'.
- In that folder, create a folder called 'com_content'.
- And in that folder, create three folders called "category", "frontpage" and "article"
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:
<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>
Change the line
echo JText::sprintf('COM_CONTENT_READ_MORE_TITLE');
into
echo JText::sprintf('COM_CONTENT_READ_MORE_TITLE', $this->item->title);
The “Read more” link should now look like this: Read more: (Article title)