Retrieving Site Template name is relatively easy when you need it within a site component. This can be done by using getTemplate()function in the following example. But what if you need to get the name of a Site Template from Administrator component or a module?
One way to get a name of the default site template name in Joomla 2.5 is to use the following code:
$app = JFactory::getApplication(); $templateName = $app->getTemplate();
However you will get an admin template name if the above code is executed from admin site. I don't believe there is a function that can retrieve a site template name regardless where you call it from. But I did find a way to get default site template name from the admin site by using the following SQL query:
$db = JFactory::getDBO(); $query = "SELECT template FROM #__template_styles WHERE client_id = 0 AND home = 1"; $db->setQuery($query); $defaultemplate = $db->loadResult();
I'll be interested to know if you know a better way to get a site template name from admin area. Please leave a comment if you do.