php 如何在 Joomla 1.5 中获取当前模板的路径?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/379920/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to get the path to the current template in Joomla 1.5?
提问by nickf
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?
你如何获得模板文件夹的正确路径?
回答by jlleblanc
IIRC, the $mainframe global object is eventually going away. Here is a way to do it through the framework:
IIRC,$mainframe 全局对象最终会消失。这是通过框架执行此操作的一种方法:
$app = JFactory::getApplication();
$templateDir = JURI::base() . 'templates/' . $app->getTemplate();
回答by Alexey Sviridov
What kind of path... On filesystem:
什么样的路径......在文件系统上:
$templateDir = JPATH_THEMES.DS.JFactory::getApplication()->getTemplate().DS;
回答by nickf
I've figured out one method. Use the global $mainframe object.
我想出了一种方法。使用全局 $mainframe 对象。
$templateDir = $mainframe->getBasePath() . "templates/" . $mainframe->getTemplate();
Is there another (better) way?
还有另一种(更好的)方法吗?

