S
S
Sergey Korenevsky2016-09-19 09:55:26
Joomla
Sergey Korenevsky, 2016-09-19 09:55:26

How to get the name of the current template in the plugin?

How to get the name of the current template in the plugin code.
simpler like

JFactory::getApplication()->getInstance()->getTemplate(TRUE);

But unfortunately this method does not produce what you need at all.
But here's the code below is very clever, and despite the fact that you need to call an additional query to the database to get the template name.
$query = " SELECT template FROM #__template_styles WHERE home=1 AND client_id=0; ";
        $template_name = JFactory::getDBO()->setQuery($query)->loadResult();

Is there any easier way?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Konstantin, 2021-05-22
@Dier_Sergio_Great

$app = JFactory::getApplication();
$template = $app->getTemplate(true);
echo $template->template;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question