No Code Attached Yet
avatar EJBJane
EJBJane
16 Aug 2025

What needs to be fixed

 mod_articles:   default_items.php

Why this should be fixed

Steps to reproduce the issue

  1. Create one or more articles with tags assigned
  2. Create an Articles module (mod_articles_news or similar)
  3. Configure the module to display tags by enabling "Show Tags" option
  4. Publish the module on a page where articles with tags are displayed
  5. View the frontend page and hover over tag links in the article list
  6. Click on tag links that don't have corresponding menu items

Expected result
Tags should either:

  • Display as clickable links that lead to proper tag pages/listings, OR
  • Display as plain text (non-clickable) if no proper tag page exists
    Introtext (optional):
  • I think here should be an option to use the metadescriptionstead of the introtext, it always truncates badly and good metadescription text usually doesnt as is limited to 160 characters (if doing it right).

Actual result

  • Tags are rendered as clickable links with href="#" when no proper tag link is available. This creates:
  • Broken links that lead nowhere (just scroll to top of page)
  • Confusing user experience - users expect clickable links to navigate somewhere
  • Invalid/meaningless anchor links in HTML output

How would you fix it

<?php

/**
 * @package     Joomla.Site
 * @subpackage  mod_articles
 *
 * @copyright   (C) 2024 Open Source Matters, Inc. <https://www.joomla.org>
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

defined('_JEXEC') or die;

use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Layout\LayoutHelper;
use Joomla\CMS\Router\Route;

if ($params->get('articles_layout') == 1) {
    $gridCols = 'grid-cols-' . $params->get('layout_columns');
}

?>
<ul class="mod-articles-items<?php echo ($params->get('articles_layout') == 1 ? ' mod-articles-grid ' . $gridCols : ''); ?> mod-list">
    <?php foreach ($items as $item) : ?>
        <?php
        $displayInfo = $item->displayHits || $item->displayAuthorName || $item->displayCategoryTitle || $item->displayDate;
        ?>
        <li>
            <article class="mod-articles-item" itemscope itemtype="https://schema.org/Article">

                <?php if ($params->get('item_title') || $displayInfo || $params->get('show_tags') || $params->get('show_introtext') || $params->get('show_readmore')) : ?>
                    <div class="mod-articles-item-content">

                        <?php if ($params->get('item_title')) : ?>
                            <?php $item_heading = $params->get('item_heading', 'h4'); ?>
                            <<?php echo $item_heading; ?> class="mod-articles-title" itemprop="name">
                                <?php if ($params->get('link_titles') == 1) : ?>
                                    <?php $attributes = ['class' => 'mod-articles-link ' . $item->active, 'itemprop' => 'url']; ?>
                                    <?php $link = htmlspecialchars($item->link, ENT_COMPAT, 'UTF-8', false); ?>
                                    <?php $title = htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8', false); ?>
                                    <?php echo HTMLHelper::_('link', $link, $title, $attributes); ?>
                                <?php else : ?>
                                    <?php echo $item->title; ?>
                                <?php endif; ?>
                            </<?php echo $item_heading; ?>>
                        <?php endif; ?>

                        <?php echo $item->event->afterDisplayTitle; ?>

                        <?php if ($displayInfo) : ?>
                            <?php $listClass = ($params->get('info_layout') == 1) ? 'list-inline' : 'list-unstyled'; ?>
                            <dl class="<?php echo $listClass; ?>">
                                <dt class="article-info-term">
                                    <span class="visually-hidden">
                                        <?php echo Text::_('MOD_ARTICLES_INFO'); ?>
                                    </span>
                                </dt>

                                <?php if ($item->displayAuthorName) : ?>
                                    <dd class="mod-articles-writtenby <?php echo ($params->get('info_layout') == 1 ? 'list-inline-item' : ''); ?>">
                                        <?php echo LayoutHelper::render('joomla.icon.iconclass', ['icon' => 'icon-user icon-fw']); ?>
                                        <?php echo $item->displayAuthorName; ?>
                                    </dd>
                                <?php endif; ?>

                                <?php if ($item->displayCategoryTitle) : ?>
                                    <dd class="mod-articles-category <?php echo ($params->get('info_layout') == 1 ? 'list-inline-item' : ''); ?>">
                                        <?php echo LayoutHelper::render('joomla.icon.iconclass', ['icon' => 'icon-folder-open icon-fw']); ?>
                                        <?php if ($item->displayCategoryLink) : ?>
                                            <a href="<?php echo $item->displayCategoryLink; ?>">
                                                <?php echo $item->displayCategoryTitle; ?>
                                            </a>
                                        <?php else : ?>
                                            <?php echo $item->displayCategoryTitle; ?>
                                        <?php endif; ?>
                                    </dd>
                                <?php endif; ?>

                                <?php if ($item->displayDate) : ?>
                                    <dd class="mod-articles-date <?php echo ($params->get('info_layout') == 1 ? 'list-inline-item' : ''); ?>">
                                        <?php echo LayoutHelper::render('joomla.icon.iconclass', ['icon' => 'icon-calendar icon-fw']); ?>
                                        <?php echo $item->displayDate; ?>
                                    </dd>
                                <?php endif; ?>

                                <?php if ($item->displayHits) : ?>
                                    <dd class="mod-articles-hits <?php echo ($params->get('info_layout') == 1 ? 'list-inline-item' : ''); ?>">
                                        <?php echo LayoutHelper::render('joomla.icon.iconclass', ['icon' => 'icon-eye icon-fw']); ?>
                                        <?php echo $item->displayHits; ?>
                                    </dd>
                                <?php endif; ?>
                            </dl>
                        <?php endif; ?>

                        <?php if (in_array($params->get('img_intro_full'), ['intro', 'full']) && !empty($item->imageSrc)) : ?>
                            <?php echo LayoutHelper::render('joomla.content.' . $params->get('img_intro_full') . '_image', $item); ?>
                        <?php endif; ?>

                        <?php if ($params->get('show_tags', 0) && $item->tags->itemTags) : ?>
                            <div class="mod-articles-tags">
                                <?php
                                // MODIFICATION: Fix broken tag links by building proper URLs
                                $tagLinks = [];
                                foreach ($item->tags->itemTags as $tag) {
                                    $title = htmlspecialchars($tag->title ?? '', ENT_COMPAT, 'UTF-8');
                                    
                                    // Build tag URL manually if ID and alias exist
                                    if (!empty($tag->id) && !empty($tag->alias)) {
                                        $tagUrl = 'index.php?option=com_tags&view=tag&id=' . $tag->id . ':' . $tag->alias;
                                        $tagLink = Route::_($tagUrl);
                                        $tagLinks[] = (object) ['link' => $tagLink, 'title' => $title];
                                    } else {
                                        // Fallback to original tag object but without broken link
                                        $tagLinks[] = (object) ['link' => '', 'title' => $title];
                                    }
                                }
                                echo LayoutHelper::render('joomla.content.tags', $tagLinks);
                                ?>
                            </div>
                        <?php endif; ?>

                        <?php echo $item->event->beforeDisplayContent; ?>

                        <?php if ($params->get('show_introtext', 1)) : ?>
                            <?php 
                            // MODIFICATION: Use metadesc instead of introtext if available
                            if (!empty($item->metadesc)) {
                                echo '<div class="mod-articles-metadesc">' . htmlspecialchars($item->metadesc, ENT_COMPAT, 'UTF-8') . '</div>';
                            } else {
                                // Fallback to original introtext
                                echo $item->displayIntrotext;
                            }
                            ?>
                        <?php endif; ?>

                        <?php echo $item->event->afterDisplayContent; ?>

                        <?php if ($params->get('show_readmore')) : ?>
                            <?php if ($params->get('show_readmore_title', '') !== '') : ?>
                                <?php $item->params->set('show_readmore_title', $params->get('show_readmore_title')); ?>
                                <?php $item->params->set('readmore_limit', $params->get('readmore_limit')); ?>
                            <?php endif; ?>
                            <?php echo LayoutHelper::render('joomla.content.readmore', ['item' => $item, 'params' => $item->params, 'link' => $item->link]); ?>
                        <?php endif; ?>
                    </div>
                <?php endif; ?>
            </article>
        </li>
    <?php endforeach; ?>
</ul>
avatar EJBJane EJBJane - open - 16 Aug 2025
avatar joomla-cms-bot joomla-cms-bot - change - 16 Aug 2025
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 16 Aug 2025
avatar EJBJane EJBJane - change - 16 Aug 2025
The description was changed
avatar EJBJane EJBJane - edited - 16 Aug 2025
avatar EJBJane EJBJane - change - 16 Aug 2025
The description was changed
avatar EJBJane EJBJane - edited - 16 Aug 2025
avatar drmenzelit
drmenzelit - comment - 16 Aug 2025

I can't reproduce the issue. I have articles with tags and they are properly linked

Image

I have no specific menu item for the tags.

You can disable the introtext truncation by setting the value to 0 (see Inline Help and Help)

avatar brianteeman
brianteeman - comment - 16 Aug 2025

I cant replicate this either.

a clean install of Joomla with the sample blog data has content items with tags and there is no tag menu type. All the tags get working links

avatar chmst
chmst - comment - 16 Aug 2025

I think here should be an option to use the metadescriptionstead of the introtext, it always truncates badly and good metadescription text usually doesnt as is limited to 160 characters (if doing it right).

I don't understand the problem. Do you have a link to show what is truncated badly?

avatar EJBJane
EJBJane - comment - 18 Aug 2025

We can close this if you guys dont have the issue. My website is very complex and I have both category links and tag links in the cards. Maybe it's just an anomaly for my largest and very complex website (I started somewhere in the Joomla 2.5ers). This indeed doesnt happen on a new Joomla 5 website.

I think here should be an option to use the metadescriptionstead of the introtext, it always truncates badly and good metadescription text usually doesnt as is limited to 160 characters (if doing it right).

I don't understand the problem. Do you have a link to show what is truncated badly?
Regarding trucation I personally dont like texts in modules truncated after the end of the p tags and on the next line. It does it here see.

Image
avatar drmenzelit drmenzelit - change - 18 Aug 2025
Status New Closed
Closed_Date 0000-00-00 00:00:00 2025-08-18 09:57:38
Closed_By drmenzelit
avatar drmenzelit drmenzelit - close - 18 Aug 2025
avatar drmenzelit
drmenzelit - comment - 18 Aug 2025

The problem with the orphaned ellipsis on truncated text is solved by #45678

Closing the issue. Feel free to open it again if you consider there is still an issue.

Add a Comment

Login with GitHub to post a comment