I have a custom form which I have made and want to display within the magento default theme (for now, until create specific css for it). To do this I have set out to try and understand magento's layouts, I've read this and this as well as a couple of other pages to try and learn the basics before I dive in, but the articles seems really unhelpful (or am I missing some nuggets of quality information?). So I had a look around at the layout files that come with magento to try and learn from them, the goal being, work out what handles I need to use. IVE FAILED, hence this question.

How do I add my form in to a Magento theme?




    <block type="core/template" name="the_form" output="toHtml" template="ps/prefcentre/signup.phtml" />

I realise the above will only render the form but how do I create this file to render a default layout around it.

Ive tried so many different options i've lost track of what ive done. From what I have read I first assumed that the default tags held within other .xml files would cause the basic template to load.

I know once I have got this I will be able to learn how to use the layouts, I'm so stuck on this point.

1 Answer 1


Your controller action should look like this:


Let's assume your module is called modulename, your controller IndexController and the action indexAction. In this case your layout file should be:

<?xml version="1.0"?>
        <reference name="content"><!-- this means you add a block to the content-->
            <block type="core/template" name="the_form" as="the_form" template="ps/prefcentre/signup.phtml" />

Basically, each action has it's own layout handled built like this: <module_controller_action>

  • That makes sense as to why each of the handles are named in the way they are. I have followed your advice, which has rendered a default template as expected, but my form is not being shown, can you offer any other options as to why it may be not working?
    – tony09uk
    Aug 9, 2013 at 13:20
  • @tony09uk. Do you see any errors in var/log? Also make sure your layout handle name matches the action name
    – Marius
    Aug 9, 2013 at 13:29
  • in var/log/layout.log - 2013-07-11T09:24:45+00:00 INFO (6): firstmodule_index_layout in var/log/system.log - 2013-07-23T07:46:57+00:00 ERR (3): Warning: simplexml_load_string(): Entity: line 10: parser error : StartTag: invalid element name in /Users/tsimps/Sites/magentoDevTest/lib/Varien/Simplexml/Config.php on line 510
    – tony09uk
    Aug 9, 2013 at 13:31
  • this means the layout file is wrongly formatted. Make sure you closed the right tags. I've edited the answer with how the full file should look. I assumed you module name is firstmodule, the controller name is index and the action name is layout based on the error message.
    – Marius
    Aug 9, 2013 at 13:49
  • Thankyou, in making the changes, i left the / off the closing tag. And thanks for teaching me where to find the error logs, that will be very useful for all my layout problems
    – tony09uk
    Aug 9, 2013 at 13:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.