【发布时间】:2011-08-12 14:12:53
【问题描述】:
我用块类创建了一个非常简单的模块。此块使用一个自定义模板,该模板调用一个类方法来确定它是否应该根据当前时间显示自己(如果支持打开,则显示电话号码)。这在我的本地开发服务器和我们的远程开发服务器上效果很好。它似乎在我们的主站点上运行良好,但今天早上我们开始在主服务器的日志中看到错误。
错误如下所示:
2011-08-11T18:14:49+00:00 ERR (3):警告:include(/chroot/home/valuepet/valuepetsupplies.com/html/app/design/frontend/base/default/template/ general/banner/orderbyphone.phtml) [function.include]: 无法打开流: 第 370 行 /chroot/home/valuepet/valuepetsupplies.com/html/var/ait_rewrite/67b58abff9e6bd7b400bb2fc1903bf2f.php 中没有这样的文件或目录
2011-08-11T18:14:49+00:00 ERR (3): Warning: include() [function.include]: Failed opening '/chroot/home/valuepet/valuepetsupplies.com/html/app/ design/frontend/base/default/template/general/banner/orderbyphone.phtml' 用于包含(include_path='/chroot/home/valuepet/valuepetsupplies.com/html/app/code/local:/chroot/home/valuepet/ valuepetsupplies.com/html/app/code/community:/chroot/home/valuepet/valuepetsupplies.com/html/app/code/core:/chroot/home/valuepet/valuepetsupplies.com/html/lib:.:/usr /share/pear') 在 /chroot/home/valuepet/valuepetsupplies.com/html/var/ait_rewrite/67b58abff9e6bd7b400bb2fc1903bf2f.php 第 370 行
我编写的模块在frontend/base/default 中没有任何内容...都在我们的自定义主题中。那么它为什么要在 base 中查找文件呢?
我添加了一些日志消息,发现它并不总是在base 中查找文件...只是偶尔。所以这表明网站中的一个页面错误地调用了该块,或者发生了一些奇怪的事情导致这种随机性。
您会从错误消息中注意到它正在对某些 PHP 脚本使用 AIT 重写。有人对这个有经验么?它带有另一个 AITOC 扩展,我找不到任何文档。也许这就是问题所在,但我的本地服务器上有相同的扩展程序,并且没有出现这个问题。
有什么想法吗?
==============================
Orderbyphone.php
class VPS_General_Block_Banner_Orderbyphone extends Mage_Core_Block_Template
{
protected $hours;
protected function _construct()
{
//GMT times for hours of operation
$this->hours = array('start' => 15,//15
'end' => 21);//20
parent::_construct();
$this->setTemplate("general/banner/orderbyphone.phtml");
}
/**
* Return true if you should show the OrderByPhone banner, false otherwise
* @return Boolean
*/
public function showBanner()
{
$GMTHour = (int)date('G');
if(($GMTHour < $this->hours['start']) || ($GMTHour >= $this->hours['end']))
{
return false;
}
return true;
}
}
orderbyphone.pthml
<?php if($this->showBanner()): ?>
<div><div class='orderbyphone'>Order By Phone 800-VALUEPET (800-825-8373)</div></div>
<?php endif; ?>
通过将以下内容添加到布局更新 XML 来将此块添加到 CMS 页面
<block type="vps_general/banner_orderbyphone" name="orderbyphone">
<action method="setWidth"><name>400</name></action>
</block>
【问题讨论】:
-
显示你的模板代码,你想在哪里包含general/banner/orderbyphone.phtml
-
我添加了代码。如果您有任何想法,请告诉我。
标签: magento themes magento-1.5