1

When displaying articles in blog layout on my website, I want the respective article link on the title and the whole intro text.

I looked at the code in components/com_content/views/category/tmpl/blog_item.php, but I was not able to find a solution.

Does anyone know how to do that?

  • You want the whole article "in place of" the intro text? – mickmackusa Sep 10 '18 at 8:41
  • 1
    no, as you see in blog layout, the link to the full article is only if you click on title. i want link on the intro text as well to the full article(e.g. if we click on intro text the whole article will open) – Brijesh Savaliya Sep 10 '18 at 9:13
  • See comment by KlintWeb below my asnwer. You certainly want to do any such changes inside a template override, to avoid losing your modifications after a Joomla Update. Sorry, I totally missed to note this in my answer. – FFrewin Sep 12 '18 at 14:35
2

Important Note after KlintWeb comment:

You certainly want to do any such changes inside a template override. Search in this site and also in the web about Joomla Template Overrides to find out how you can create them.


How to wrap the intro-text inside a link to the article:

In components/com_content/views/category/tmpl/blog_item.php there is a piece of code:

<?php echo $this->item->introtext; ?>

This one echoes the introtext of the article.

A a few lines below, there is:

<?php if ($params->get('show_readmore') && $this->item->readmore) :
    if ($params->get('access-view')) :
        $link = JRoute::_(ContentHelperRoute::getArticleRoute($this->item->slug, $this->item->catid, $this->item->language));
    else :
        $menu = JFactory::getApplication()->getMenu();
        $active = $menu->getActive();
        $itemId = $active->id;
        $link = new JUri(JRoute::_('index.php?option=com_users&view=login&Itemid=' . $itemId, false));
        $link->setVar('return', base64_encode(ContentHelperRoute::getArticleRoute($this->item->slug, $this->item->catid, $this->item->language)));
    endif; ?>

This one generates the link for the read-more button (if the button is enabled). It also takes into consideration if the content is restricted.


So, now you have all the needed elements to do what you want to do.

Just wrap your intro-text with an <a> element and use the article link for the href attribute.


*If you don't have restricted content, then just use:

$link = JRoute::_(ContentHelperRoute::getArticleRoute($this->item->slug, $this->item->catid, $this->item->language));

  • This will not work forever. It might get overridden by an update in the future. My advice is never to make changes in the core files. Especially not, when you can make overrides in templates/your-template/html/... – KlintWeb Sep 12 '18 at 13:26
  • @KlintWeb - you are absolutely right. I completely missed to mention this. – FFrewin Sep 12 '18 at 14:34

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.