Is it possible to inject an HTML code to a block without using modules only? Without the need to copy anything to the ./app/design/ directory? Or is it actually a normal practice for Magento 1.9 modules to also place files in the ./app/design/ directory?

  • did my answer solve your issue? Commented Dec 1, 2017 at 8:39

2 Answers 2


You could also add custom code/files using layout XML in your theme.

A simple example would be if in [magento-root]/app/design/[package]/[theme]/layout/local.xml, you added:

    <reference name="content">
            <block type="core/template" name="some.name" template="path/to/example.phtml" />

Any code you then put in [magento-root]/app/design/[package]/[theme]/template/path/to/example.phtml would be added to every page (the <default> handle) and it would be placed near the end of the main content (the <reference name="content"> tag).

It takes a while to learn a quick way to find the specific block that you want to add to and place your code in a specific place, but you can use this to add custom content without copying files to your theme.

A good place to start in locating the files is in Admin->System->Configuration->Advanced->Developer->Debug->Template Path Hints. Note: This can only be enabled at the website/Store View scope-level

That would give you the path for the .phtml file, then you can search for that filepath in any file under app/design/frontend/*/*/layout/ to find the name of the block/other details. For more information on layout XML, Magento DevDocs Pt 4 is a good place to start.


You can directly add scripts such as google tag manager that are to be added directly in the head and included in every page in System->Configuration->Design->Head in admin , but for more specific tasks than that you will have to work with your theme files.

And yes, it is normal practice to do so.

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.