【问题标题】:How to get the path to the current template in Joomla 1.5?如何在 Joomla 1.5 中获取当前模板的路径?
【发布时间】:2008-12-19 01:59:52
【问题描述】:

我正在编写一个组件,并想从模板文件夹中插入图像。

如何获得模板文件夹的正确路径?

【问题讨论】:

    标签: php joomla joomla1.5


    【解决方案1】:

    IIRC,$mainframe 全局对象最终会消失。这是通过框架实现的一种方法:

    $app = JFactory::getApplication();
    $templateDir = JURI::base() . 'templates/' . $app->getTemplate();
    

    【讨论】:

    • 以及如何获取管理员模板?
    【解决方案2】:

    什么样的路径... 在文件系统上:

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

    【讨论】:

      【解决方案3】:

      我想出了一种方法。使用全局 $mainframe 对象。

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

      还有其他(更好的)方法吗?

      【讨论】:

      • 在我看来这是最好的方法。
      猜你喜欢
      • 2015-06-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-11-21
      • 2016-06-04
      • 2018-03-11
      • 2019-09-04
      • 1970-01-01
      相关资源
      最近更新 更多