我用块类创建了一个非常简单的模块。此块使用一个自定义模板,该模板调用一个类方法来确定它是否应该根据当前时间显示自己(如果支持打开,则显示电话号码)。这在我的本地开发服务器和我们的远程开发服务器上效果很好。它似乎在我们的主站点上运行良好,但今天早上我们开始在主服务器的日志中看到错误。
错误如下所示:
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]:无法打开流:/chroot/home/valuepet/valuepetsupplies.com/html/var/ait_rewrite/67b58abff9e6bd7b400bb2fc1903bf2f.php 中没有这样的文件或目录在第 370 行
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') 在第 370 行的 /chroot/home/valuepet/valuepetsupplies.com/html/var/ait_rewrite/67b58abff9e6bd7b400bb2fc1903bf2f.php
我写的模块中没有任何内容frontend/base/default
......它都在我们的自定义主题中。那么它为什么要查找base
文件呢?
我添加了一些日志消息,发现它并不总是在base
...中查找文件,只是偶尔。因此,这表明站点中的一个页面错误地调用了该块,或者发生了一些奇怪的事情导致这种情况随机发生。
您会从错误消息中注意到它正在对某些 PHP 脚本使用AIT Rewrite。有人对这个有经验么?它带有另一个 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>