Knowledgebase

How to fix the error "Fatal error: Call to a member function toHtml() on a non-object" in Magento

Very often when installing a new Magento theme you will get the following error:

Fatal error: Call to a member function toHtml() on a non-object in <your_Magento_installation_folder>/app/code/core/Mage/Core/Model/Layout.php on line 529

To fix the error you need to open the page.xml file of the new theme and edit it. The path to that file is:

your_Magento_installation_folder/app/design/frontend/default/your_new_theme/layout/page.xml

where your_Magento_installation_folder is the directory where your Magento is installed and your_new_theme is the directory of your new Magento theme.

Open the page.xml file, find this line:

<block type="core/profiler" output="toHtml"/>

and change it to:

<block type="core/profiler" output="toHtml" name="core_profiler"/>

You can edit the file by downloading it with your favorite FTP client (e.g. FileZilla), editing it with a text editor (e.g. Notepad) and then uploading it back to your Magento directory, overwriting the old file.

Another way to modify the file is to connect to your web hosting account via SSH and open the file using vim or nano. HostKnox offers free SSH access for all hosting accounts, so all of our customers can take advantage of this feature.

A third way of editing the file is to use the tools your control panel provides. HostKnox customers can edit files using the File Manager in the Pixie control panel.

When you are ready and the modified page.xml file is in place, flush the Magento cache and reload your site to see your new theme.

Was this answer helpful?

 Print this Article

Also Read