tags:

views:

4017

answers:

3

I'm writing a component and would like to insert images from the template folder.

How do you get the correct path to the template folder?

A: 

I've figured out one method. Use the global $mainframe object.

$templateDir = $mainframe->getBasePath() . "templates/" . $mainframe->getTemplate();

Is there another (better) way?

nickf
Looks to me as if this is the best way.
Steven Oxley
+4  A: 

IIRC, the $mainframe global object is eventually going away. Here is a way to do it through the framework:

$app =& JFactory::getApplication();
$templateDir = JURI::base() . 'templates/' . $app->getTemplate();
jlleblanc
+1  A: 

What kind of path... On filesystem:

$templateDir = JPATH_THEMES.DS.JFactory::getApplication()->getTemplate().DS;

Alexey Sviridov