Magento: Adding contacts form to footer

Magento: Adding contacts form to footer

September 10, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento: Adding contacts form to footer

Adding a Contacts Form to Your Magento Footer

As a new Magento developer, you might be wondering how to add the built-in contact form to your theme’s footer area. While the default setup allows for a dedicated contacts page, integrating it into the footer can provide an alternative way for customers to reach out directly from any page.

Understanding the Current Setup

Let’s analyze the provided code snippets and understand what’s happening:

  1. You’ve created a new form.phtml file in your custom theme (app/design/frontend/default/mytheme/template/contacts/form.phtml). This is where the contact form HTML will be rendered.

  2. In your layout XML file (app/design/frontend/default/mytheme/layout/page.xml), you’re adding a new block of type “contacts/form” and naming it “form”. You’re also specifying the template for this block to be the previously created form.phtml file.

  3. In your footer template file (app/design/frontend/default/mytheme/template/page/html/footer.phtml), you’ve added a div with an id of “contact-form”. This is where the contact form should theoretically get rendered by Magento’s layout system.

The Issue at Hand

The problem lies in how you’re trying to echo the contact form block. In your footer template, you’re calling getChildHtml('contact-form') instead of getChildHtml('form').

By convention, when adding blocks via XML layouts, we typically use a unique name for each block. However, when printing or echoing these blocks in our templates, we need to reference the exact name specified in the layout XML.

The Solution: Correctly Referencing the Block

To fix this issue and correctly display the contact form in your footer, you simply need to modify the line of code in your footer template:

// Change this
<?php echo $this->getChildHtml('contact-form') ?>

// To this
<?php echo $this->getChildHtml('form') ?>

By changing contact-form to form, you’re now correctly referencing the block named “form” that you defined in your layout XML. This will then render the contact form created with app/design/frontend/default/mytheme/template/contacts/form.phtml.

Best Practices and Further Customization

While this solution should resolve the immediate issue, keep a few things in mind:

  1. Always double-check your layout XML file to ensure you’re using unique names for each block.

  2. When referencing these blocks in your templates, make sure to match the exact name specified in the XML.

  3. If you need to customize the appearance or behavior of the contact form beyond what’s provided by Magento, consider studying the official Magento documentation on form rendering: https://laravelcompany.com/2021-magento-form-rendering-explained/.

Conclusion

Adding a contacts form to your Magento footer involves understanding the layout system, creating the necessary template files, and correctly referencing blocks in both XML and PHP. By following the steps outlined here and adhering to best practices, you should now be able to successfully display the built-in contact form in your theme’s footer.

Remember, Magento’s layout system is powerful but can sometimes feel complex for new developers. With practice and understanding of its conventions, you’ll find it increasingly intuitive to customize your storefront to meet your specific business needs.

Happy coding!

Themes Customers Errors

Our network