Technical Library / Open Source

Joomla Snippets

Searchable collection of production-ready code recipes for template overrides, modules, plugins, and Joomla! 3 to 6 APIs.

100 Snippets
12 Categories
J3 to J6 Compatibility
Showing 6 of 6 snippets
PHP J6 J5 J3 Template Override
Modules and Positions

Render Modules from Any Position Anywhere in Joomla

Loads and renders every published module assigned to a custom position inside overrides, components or templates.

<?php

declare(strict_types=1);

use Joomla\CMS\Helper\ModuleHelper;

$position = 'contato-direita';
// ...
82 324 2 versions
PHP J6 J5 J3 Template
Modules and Positions

Check Published Modules in Positions with countModules()

Dynamically calculates Bootstrap 5 main and sidebar column widths based on active modules in sidebar-left and sidebar-right.

<?php

declare(strict_types=1);

$hasLeft  = $this->countModules('sidebar-left', true) > 0;
$hasRight = $this->countModules('sidebar-right', true) > 0;
$mainCol  = ($hasLeft && $hasRight) ? 'col-lg-6' : (($hasLeft || $hasRight) ? 'col-lg-9' : 'col-12');
// ...
46 171 2 versions
PHP J6 J5 Module
Modules and Positions

Create Modern services/provider.php for a Joomla 5 and 6 Module

Registers ModuleDispatcherFactory, HelperFactory and the Module service via the DI Container without a legacy mod_example.php entry file.

<?php

declare(strict_types=1);

\defined('_JEXEC') or die;

use Joomla\CMS\Extension\Service\Provider\HelperFactory;
// ...
58 193
PHP J6 J5 Module
Modules and Positions

Create a Modern Module Dispatcher Extending AbstractModuleDispatcher

Implements getLayoutData() with HelperFactoryAwareTrait to inject clean data into module tmpl layouts.

<?php

declare(strict_types=1);

namespace Vendor\Module\Example\Site\Dispatcher;

\defined('_JEXEC') or die;
// ...
52 176
PHP J6 J5 J3 Template Override
Modules and Positions

Render a Specific Module by Type and Title via ModuleHelper

Loads and renders a single module instance by module name (e.g. mod_finder) and exact title regardless of position.

<?php

declare(strict_types=1);

use Joomla\CMS\Helper\ModuleHelper;

$module = ModuleHelper::getModule('mod_finder', 'Busca Global');
// ...
29 120 2 versions
PHP J6 J5 J4 Template
Modules and Positions

Create a Custom Module Chrome in html/layouts/chromes/

Defines a reusable Joomla 4, 5 and 6 module chrome layout replacing legacy html/modules.php functions.

<?php

declare(strict_types=1);

\defined('_JEXEC') or die;

$module  = $displayData['module'];
// ...
36 141
Direct Engineering

Have a Joomla project or technical challenge in mind?

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