PHP Joomla! 6 Joomla! 5 Joomla! 3 (Legacy) Module Intermediate

List Published Items from a Specific Menu by menutype

Queries top-level items of a specific menu using $app->getMenu()->getItems() with built-in ACL and language filtering.

Updated on 24 November 2026 28 copies 111 views
modules/mod_example/src/Helper/NavHelper.php
<?php

declare(strict_types=1);

use Joomla\CMS\Factory;
use Joomla\CMS\Router\Route;

$menu  = Factory::getApplication()->getMenu();
$items = $menu->getItems(['menutype', 'level'], ['mainmenu-pt-br', 1]);

foreach ($items as $item) {
    $href = Route::_('index.php?Itemid=' . (int) $item->id);
    echo '<a href="' . htmlspecialchars($href, ENT_QUOTES, 'UTF-8') . '">' . htmlspecialchars($item->title, ENT_QUOTES, 'UTF-8') . '</a>';
}
Respects user access levels and active language automatically.
modules/mod_example/src/Helper/NavHelper.php
<?php
$menu  = JFactory::getApplication()->getMenu();
$items = $menu->getItems('menutype', 'mainmenu');
Classic Joomla 3 call via JFactory::getApplication()->getMenu()->getItems().

Technical explanation and best practices

Joomla SiteMenu caches all published menu items in memory. Filtering by menutype and level with getItems() is fast and zero-query for footers or custom nav bars.

Direct Engineering

Have a Joomla project or technical challenge in mind?

From architectural diagnosis to production deployment, directly with the engineer.