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

Get the Active Template Base Path

Builds the clean relative URL for the active template directory and its modern /media/templates/site/ folder.

Updated on 24 November 2026 28 copies 124 views
templates/seu_template/index.php
<?php

declare(strict_types=1);

use Joomla\CMS\Factory;
use Joomla\CMS\Uri\Uri;

$app           = Factory::getApplication();
$templateName  = $app->getTemplate();
$templatePath  = Uri::root(true) . '/templates/' . $templateName . '/';
$mediaPath     = Uri::root(true) . '/media/templates/site/' . $templateName . '/';
Provides both the template directory path and the modern /media/templates/site/ asset path.
templates/seu_template/index.php
<?php
$app   = JFactory::getApplication();
$tpath = JURI::base(true) . '/templates/' . $app->getTemplate() . '/';
Legacy Joomla 3 version using JURI::base(true).

Technical explanation and best practices

In Joomla 5 and 6, template static assets live under /media/templates/site/<template>/ while PHP layouts reside in /templates/<template>/.

Use Uri::root(true) (replacing deprecated JURI::base(true)) along with $app->getTemplate().

Direct Engineering

Have a Joomla project or technical challenge in mind?

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