PHP Joomla! 6 Joomla! 5 Joomla! 3 (Legacy) Template Basic

Get the Page Class Suffix (pageclass_sfx) of the Active Menu

Safely retrieves the CSS Page Class (pageclass_sfx) configured under the active menu item Display tab.

Updated on 24 November 2026 37 copies 155 views
templates/seu_template/index.php
<?php

declare(strict_types=1);

use Joomla\CMS\Factory;

$active       = Factory::getApplication()->getMenu()->getActive();
$pageclassSfx = $active ? trim((string) $active->getParams()->get('pageclass_sfx', '')) : '';
Prevents null errors on 404 routes and sanitizes output for HTML class attributes.
templates/seu_template/index.php
<?php
$pageclass_sfx = JFactory::getApplication()->getMenu()->getActive()->params->get('pageclass_sfx');
Original one-liner from Joomla 3.

Technical explanation and best practices

Commonly printed on the template <body> element so editors can toggle custom section styles or landing page layouts directly from Joomla Menu Manager.

Direct Engineering

Have a Joomla project or technical challenge in mind?

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