Mageician
Mageician

Reputation: 2927

Why is Magento looking in 'base/default' for my template file?

I created a really simple module with a block class. This block uses a custom template that calls a class method to determine if it should show itself or not based on the current time of day (if support is open, show the phone number). This works great on my local dev server and our remote dev server. It seems to work well on our main site, but we started seeing errors in the log this morning on the main server.

The errors looked like this:

2011-08-11T18:14:49+00:00 ERR (3): Warning: include(/chroot/home/valuepet/valuepetsupplies.com/html/app/design/frontend/base/default/template/general/banner/orderbyphone.phtml) [function.include]: failed to open stream: No such file or directory in /chroot/home/valuepet/valuepetsupplies.com/html/var/ait_rewrite/67b58abff9e6bd7b400bb2fc1903bf2f.php on line 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' for inclusion (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') in /chroot/home/valuepet/valuepetsupplies.com/html/var/ait_rewrite/67b58abff9e6bd7b400bb2fc1903bf2f.php on line 370

The module I wrote doesn't have anything in frontend/base/default...it's all in our custom theme. So why was it looking in base for the files?

I added some log messages and found that it doesn't ALWAYS look for the file in base...only occasionally. So that suggests that either one page in the site is calling the block incorrectly or there's something strange going on that causes this randomly.

You'll notice from the error message that it's using AIT Rewrite for some of the PHP scripts. Does anyone have any experience with this? It came with another AITOC extension and I can't find any documentation on it. Perhaps that's the problem, but I have that same extension on my local server and this problem doesn't come up.

Any ideas?

=============================

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; ?>

This block is added to a CMS pages by adding the following to the Layout Update XML

<block type="vps_general/banner_orderbyphone" name="orderbyphone">
    <action method="setWidth"><name>400</name></action>
</block>

Upvotes: 1

Views: 3170

Answers (1)

Alessandro Ronchi
Alessandro Ronchi

Reputation: 675

considering Magento's cascading way of searching for template assets the fact that it doesn't find an asset in /base/default/ doesn't necessarily mean that you specified that path.

In fact if you tell Magento to load a template asset in /yourpackage/yourtheme/ path and Magento doesn't find that asset it will search for the same asset in /base/default/ path.

If it doesn't find it even in /base/default/ it will throw an exception saying that the resource wasn't fount in the /base/default/ not in /yourpackage/yourtheme/ path.

I don't know if this is the case but maybe it can help you a bit. In other words: are you sure the resource you are looking for is in /yourpackage/yourtheme/ path?

Pay attention to the fact that file names are case sensitive under Unix/Linux so what is found under Windows is not necessarily found under Unix/Linux.

Regards, Alessandro

Upvotes: 2

Related Questions