Magento – How to Render Header and Footer in Custom Controller

controllersfooterheaderlayout

I'm creating a custom controller that uses the same header and footer as the rest of the site, but will be using custom code to serve content, but I also need to exclude them based on query parameters (hence why I'm not using a template file in a cms page for this)

My question is how can I call upon these in a controller? Does renderLayout() accept parameters such as renderLayout('header'), etc.?

Best Answer

When you call loadlayout() and renderlayout() in the controller of your model, magento will look for the respective xml(layout) file for your module. In layout file, you can add your content by referencing the content, left or right structure blocks. This automatically loads the header and footer for your file.

You do something like this:

<yourmodule_index_index> 
<reference name="content> 
<!-- CALL YOUR BLOCK HERE -->
</reference>
</yourmodule_index_index>
Related Topic