This Joomla 4 override allows you to display a glossary with its index simply using Joomla's mod_articles_category and mod_articles_categories modules. At the bottom of this article, you can download the files of the override.

Joomla 4 frontend rendering

The index

PhP markup mod_articles_categories/default.php

<?php
/**
 * @package     Joomla.Site
 * @subpackage  mod_articles_categories
 * @author	    web-eau.net
 * @copyright   (C) 2010 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\Helper\ModuleHelper;

if (!$list)
{
	return;
}

?>
<!-- Only added few Bootstrap 5 classes to display the index horizontaly and centered -->
<ul class="mod-articlescategories categories-module mod-list list-group list-group-horizontal d-flex justify-content-center">
	<?php require ModuleHelper::getLayoutPath('mod_articles_categories', $params->get('layout', 'glossary-index') . '_glossary-items'); ?>
</ul>

PhP markup mod_articles_categories/default_items.php

<?php
/**
 * @package     Joomla.Site
 * @subpackage  mod_articles_categories
 * @author	    web-eau.net
 * @copyright   (C) 2010 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\Helper\ModuleHelper;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Router\Route;
use Joomla\Component\Content\Site\Helper\RouteHelper;

$input  = $app->input;
$option = $input->getCmd('option');
$view   = $input->getCmd('view');
$id     = $input->getInt('id');

foreach ($list as $item) : ?>
	<li<?php if ($id == $item->id && in_array($view, array('category', 'categories')) && $option == 'com_content') echo ' class="list-group-item active"'; ?>> <?php $levelup = $item->level - $startLevel - 1; ?>
		<a href="<?php echo Route::_(RouteHelper::getCategoryRoute($item->id, $item->language)); ?>" class="me-2 fs-5 badge badge-primary">
		<?php echo $item->title; ?>
			<?php if ($params->get('numitems')) : ?>
				(<?php echo $item->numitems; ?>)
			<?php endif; ?>
		</a>

		<?php if ($params->get('show_description', 0)) : ?>
			<?php echo HTMLHelper::_('content.prepare', $item->description, $item->getParams(), 'mod_articles_categories.content'); ?>
		<?php endif; ?>
		<?php if ($params->get('show_children', 0) && (($params->get('maxlevel', 0) == 0)
			|| ($params->get('maxlevel') >= ($item->level - $startLevel)))
			&& count($item->getChildren())) : ?>
			<?php echo '<ul>'; ?>
			<?php $temp = $list; ?>
			<?php $list = $item->getChildren(); ?>
			<?php require ModuleHelper::getLayoutPath('mod_articles_categories', $params->get('layout', 'default') . '_items'); ?>
			<?php $list = $temp; ?>
			<?php echo '</ul>'; ?>
		<?php endif; ?>
	</li>
<?php endforeach; ?>

The glossary

PhP markup mod_articles_category

<?php
	/**
		* @package     Joomla.Site
		* @subpackage  mod_articles_category
		* @author	   web-eau.net
		* @copyright   (C) 2010 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\Helper\ModuleHelper;
	use Joomla\CMS\Language\Text;
	use Joomla\CMS\Layout\LayoutHelper;
	use Joomla\CMS\Helper\HTMLHelper;
	
	if (!$list)
	{
		return;
	}
	
?>

<ul class="mod-articlescategory category-module mod-list row row-cols-1 row-cols-md-4 g-4"> <!-- because we want 4 columns -->

	<?php foreach ($list as $groupName => $items) : ?>
	<li>
		<div class="mod-articles-category-group"><?php echo Text::_($groupName); ?></div>
		<ul>
			
			<?php foreach ($items as $item) : ?>
			<li>
				<?php if ($params->get('link_titles') == 1) : ?>
				<a class="mod-articles-category-title <?php echo $item->active; ?>" href="<?php echo $item->link; ?>">
					<?php echo $item->title; ?>
				</a>
				<?php else : ?>
				<?php echo $item->title; ?>
				<?php endif; ?>
				
				
				<?php if ($params->get('show_introtext')) : ?>
				<p class="mod-articles-category-introtext">
					<?php echo $item->displayIntrotext; ?>
				</p>
				<?php endif; ?>
				
			</li>
			<?php endforeach; ?>
			
		</ul>
	</li>
	<?php endforeach; ?>

</ul>
 

web-eau.net

France - 29800 Landerneau

+33 674 502 799

daniel@web-eau.net

Quick links