dongmen1860 2014-06-19 15:40
浏览 38
已采纳

Magento - 在phtml模板文件中包含/要求php文件

In one of my magento template phtml files I am trying to include a seperate php file. When I include it I get nothing outputted and when i use require instead I get the following error

Fatal error: require(): Failed opening required 'http://www.site.co.uk/dir/test.php'
(include_path='/home/usr/public_html/app/code/local:/home/usr/public_html/app/code/community:/home/usr/public_html/app/code/core:/home/usr/public_html/lib:.:/usr/lib/php:/usr/local/lib/php') in /home/usr/public_html/app/design/frontend/theme/edits/template/review/product/view/list.phtml on line 30

The first line of the error shows the correct url path and when i go to it directly it works - it just doesn't like being included/required from the phtml template page.

I've tried the following in the phtml file (using magento's BaseURL, absolute path and the relative path):

<?php 
$root = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
require/include ($root.'dir/test.php');
?>

<?php 
require/include ('http://www.site.co.uk/dir/test.php');
?>

<?php 
require/include ('../../../../../../../../../dir/test.php');
?>
  • 写回答

2条回答 默认 最新

  • double0201 2014-06-19 16:02
    关注

    Instead of Mage::getBaseUrl use $root = Mage::getBaseDir();

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?