Tuesday 5 May 2015

Custom Layout not loaded

The cause of this issue 

The handle name is always lower-cased by magento which led my failure of loading my layouts.

An efficient way to sort it out

Magento's front-end including handles, layouts, blocks and templates. Among all of them, handles are the only kind of things that will cause failing to load the layouts without any errors or notices. So print the handles in the controller and compare it with the handles defined in the layout XML file.

Here is what I did. First, use the below code to print the handles in the controller:
var_dump($this->getLayout()->getUpdate()->getHandles());

Then, copy the handle name called 'importjson' in my case and search it case-sensitively in the layout file. The result is that 'importjson' couldn't be found in the file that only contains the string of 'importJson'.

To conclude, in Magento we should always pay attention to case-sensitive which could cause numerous issues and cost us a lot time to figure it out.