Working with Magento CE

I have written some custom code which I have placed here:


I also created a new XML reference to this file here:


This is the reference I added within the layout block:

  <reference name="before_body_end">
      <block type="core/template"  name="my_custom_code" template="template/page/html/custom_code.phtml" />

However after clearing cache and verifying there are no errors anywhere on the system, I still can't get the block to show before_body_end anywhere on the homepage. What am I doing wrong?

1 Answer 1


The template location is wrong.

Assume that your template is located at app/design/frontend/Your_Pakage/Your_Theme/template/page/html/custom_code.phtml.

Magento,design fall back logic it would be automatically at app/design/frontend/Your_Pakage/Your_Theme/template/.

So you need just add page/html/custom_code.phtml instead of template/page/html/custom_code.phtml.

Use template="page/html/custom_code.phtml" instead of template="template/page/html/custom_code.phtml"

  • Thank you Amit. I noticed that as well. I updated my reference, cleared cache and checked again but still no luck. Upvoted because it was indeed a contributing factor. is page.xml the correct place to reference my block? Should I instead be doing it in local.xml?
    – sparecycle
    Mar 29, 2016 at 17:27
  • yes.cms_index_index only called at home. So note that ur code wil only run at home . page. If you want to run at all pages then default handler <default> instead of '<cms_index_index>
    – Amit Bera
    Mar 29, 2016 at 17:36
  • And there is no need for a module of any sort? This can be accomplished with the two files I referenced above?
    – sparecycle
    Mar 29, 2016 at 17:40
  • no need of extension
    – Amit Bera
    Mar 29, 2016 at 18:16
  • It worked! That was it. It seemed to have been delayed by file caching. Thanks Amit.
    – sparecycle
    Mar 29, 2016 at 18:18

Your Answer

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

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