mod_articles: default_items.php
Steps to reproduce the issue
Expected result
Tags should either:
Actual result
<?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>
Labels |
Added:
No Code Attached Yet
|
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
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?
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.
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2025-08-18 09:57:38 |
Closed_By | ⇒ | drmenzelit |
I can't reproduce the issue. I have articles with tags and they are properly linked
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)