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

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>

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

Related

Joomla - Fatal error: Class 'JParameter' not found

I'm trying to upgrade Joomla 2.5.22 to 3.5.1, and last time I checked the progress bar, it was 86 %. I looked away for a moment and when I came back to check I saw the below error message.
Fatal error: Class 'JParameter' not found in
/home/mywebsite/public_html/plugins/system/bigshotgoogleanalytics/bigshotgoogleanalytics.php on line 24
What is the cause of this error and how would it be fixed?
Joomla can't find JParameter Class, so you have to use
jimport( 'joomla.html.parameter' );
before using JParameter class
bigshotanalytics is one of those plugins that cause a blank page or, at best, a fatal error when updating Joomla. This is because of its old code. I suggest you move the tracking code to your template. You can also add the tracking code to a custom HTML module (after removing the encapsulating div through an override) and then assign the module to a position in your template (the position should be in the section of the HTML).
Now to answer your question, Joomla no longer uses JParameter - it uses JRegistry instead. So something like:
$jparameter = new JParameter('param1');
Should be changed to:
$jregistry= new JRegistry();
$jparameter = $jregistry->get('param1');

Getting the filename/path from MvvmCross Plugins.DownloadCache

I'm currently using MvvmCross DownloadCache -- and it's working alright -- especially nice when I just need to drop in an Image URL and it automagically downloads / caches the image and serves up a UIImage.
I was hoping to leverage the code for one other use case -- which is I'd like to grab source images from URL's and cache the files on the local file system, but what I really want for this other use case is the image path on the local file system instead of the UIImage itself.
What would help me most if I could get an example of how I might accomplish that. Is it possible to make that happen in a PCL, or does it need to go into the platform specific code?
Thanks -- that works, but just in case anyone else is following along, I wanted to document how I got the Mvx.Resolve<IMvxFileDownloadCache>() to work. In my setup.cs (in the touch project), I had:
protected override void InitializeLastChance ()
{
Cirrious.MvvmCross.Plugins.DownloadCache.PluginLoader.Instance.EnsureLoaded();
Cirrious.MvvmCross.Plugins.File.PluginLoader.Instance.EnsureLoaded();
Cirrious.MvvmCross.Plugins.Json.PluginLoader.Instance.EnsureLoaded();
...
}
But that wasn't enough, because nothing actually registers IMvxFileDownloadCache inside the DownloadCache plugin (which I was expecting, but it's just not the case).
So then I tried adding this line here:
Mvx.LazyConstructAndRegisterSingleton<IMvxFileDownloadCache, MvxFileDownloadCache>();
But that failed because MvxFileDownloadCache constructor takes a few arguments. So I ended up with this:
protected override void InitializeLastChance ()
{
...
var configuration = MvxDownloadCacheConfiguration.Default;
var fileDownloadCache = new MvxFileDownloadCache(
configuration.CacheName,
configuration.CacheFolderPath,
configuration.MaxFiles,
configuration.MaxFileAge);
Mvx.RegisterSingleton<IMvxFileDownloadCache>(fileDownloadCache);
...
}
And the resolve works okay now.
Question:
I do wonder what happens if two MvxFileDownloadCache objects that are configured in exactly the same way will cause issues by stepping on each other. I could avoid that question by changing the cache name on the one I'm constructing by hand, but I do want it to be a single cache (the assets will be the same).
If you look at the source for the plugin, you'll find https://github.com/MvvmCross/MvvmCross/blob/3.2/Plugins/Cirrious/DownloadCache/Cirrious.MvvmCross.Plugins.DownloadCache/IMvxFileDownloadCache.cs - that will give you a local file path for a cached file:
public interface IMvxFileDownloadCache
{
void RequestLocalFilePath(string httpSource, Action<string> success, Action<Exception> error);
}
You can get hold of a service implementing this interface using Mvx.Resolve<IMvxFileDownloadCache>()
To then convert that into a system-wide file path, try NativePath in https://github.com/MvvmCross/MvvmCross/blob/3.2/Plugins/Cirrious/File/Cirrious.MvvmCross.Plugins.File/IMvxFileStore.cs#L27

Magento Mage class causes server error 500 in own php script

I got a few problems with the Mage Class, when we try to call any static method, e. g. in my case:
Mage::getModel('catalog/product')->load($productId);
It always causes an error 500. It´s been used in an own php design file.
Also, this post didn´t resolve the problem: Magento 1.7 - getModel in script outside web application fails
I searched a lot in the internet and found out, that
Mage::getModel();
is a factory method, so I actually don´t need to call
Mage::getConfig()->init();
Mage::getConfig()->loadModules();
Help me, please!
Edit: I solved the error with this code:
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
$category = Mage::getModel('catalog/category')->load($categoryId);
$prodCollection = Mage::getResourceModel('catalog/product_collection')->addCategoryFilter($category);
$prodCollection->addAttributeToSelect('attribute_name');
The main problem was, that this line was missing:
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
The error might be caused by this:
Mage::getModel()->('catalog/product')->load($productId);
This is wrong. First of all getModel expects at least a parameter. Second, there is no method name here ->('catalog/product'). Your code should be:
Mage::getModel('catalog/product')->load($productId);
Also make sure that Mage.php is included in your script otherwise the class is not found.

I cannot access my controller of my new Magento module (tutorial help)

I am making a Magento module which is enabled, and my cache is off.
Using this tutorial...
http://www.pierrefay.com/magento-create-controller-36
Here's the controller I was asked to use in app/code/local/Pfay/Test.
class Pfay_Test_IndexController extends Mage_Core_Controller_Front_Action
{
public function indexAction ()
{
echo 'test index';
}
public function mamethodeAction ()
{
echo 'test mymethod';
}
}
However when I go to magento/Pfay/Test/index in my web browser, I get a 404 page, not the controller.
In the example code that you are copying and pasting, there are spaces in betweeen the following tags in the Pfay_All.xml file:
<active> true </active>
<codePool> local </codePool>
Remove those spaces so the tags look exactly like this:
<active>true</active>
<codePool>local</codePool>
Also, the path you are using should be /test/index or /test and not /Test/index - i.e. no uppercase T in Test
Try any one of the below codes.
magento/Test/index or magento/Test or magento/test
The namespace is only for grouping the modules.
Some mistakes found in the tutorial
The tutorial says to use Test in the url but there should be no uppercase in the url, just lowercase.
Another mistake in the tutorial is that the <routeurfrontend></routeurfrontend> tags should instead be <test></test>. You can update this in local/Pfay/Test/etc.
indexController.php should instead be called IndexController.php (note the capital i)
Also read the other answers. The other answers are useful because the person who wrote the tutorial is bad at English, so it can be confusing to read. You'll find a 3rd mistake corrected in them, so look up.

when might magento Mage::getModel('customer/form'); fail?

I have the following two lines of code in within a controller class.
$customerForm = Mage::getModel('customer/form');
$customerForm->setFormCode('customer_account_create')
->setEntity($customer);
I am getting "Fatal error: Call to a member function setFormCode() on a non-object in ..."
on the second of those two lines.
what might cause the first line to return a "non-object" ? (I guess it fails and returns a null but why would this happen ?)
I am not sure if this is relevant but this is happening in a site that uses the Enterprise version of magento (Magento ver. 1.8.0.0).
Look into your exeption.log, you should find some ideas there. It might happen if Mage_Customer module is disabled, you have rewrite for 'customer/form' model, or even file with Mage_Customer_Model_Form class is missing.

Resources