0

I've made an extension that requires some dynamically set .js and .css files. Using the default theme I added them in through a template set in a block in the head like this:

in ...\app\design\frontend\default\default\layout\myextension.xml

<layout version="0.1.0">
   <...>
    <default>
        <reference name="head">
                    <block type="core/template" name="myextension" template="myextension/mymodule/myincludes.phtml" />          
        </reference>            
    </default>
    <...>
</layout>

Which calls my file located at ...app\design\frontend\default\default\template\myextension\mymodule\myincludes.phtml and declared it in my extension's config.xml thusly:

<config>    
    <...>
    <frontend>
    <...>
        <layout>
            <updates>
                <mymodule>
                    <file>myextension.xml</file>
                </mymodule>
            </updates>
        </layout>
    </frontend>
    <...>
    </default>
    <adminhtml>
    <...>
     <layout>
        <updates>
            <myextension>
                <file>myextension.xml</file>
            </myextension>
        </updates>
    </layout>
    </adminhtml>
</config>

This all works wonderfully on the default theme, my template is added to the theme, and the js and css files it calls work perfectly and make me happy. When I switch to the theme "flatastic" my "myincludes.phtml" doesn't seem to get added to the head and everything breaks.

I should add that the other parts of my extension seem to work fine even when the layout changes don't. For example all my admin config options are fine, a controller is still accessible, etc.

I'm new to magento, and assumed that the theme was just overwriting some of the templates I had changed, but i'm calling a completely custom template in a new block.

Am I doing something wrong in the way I add it?

Does a different theme add considerations I don't know about yet?

What should I look for when a theme breaks my layout changes in an extension?

0

To understand the problem you have you need to know how magento theme fallback is working. If you create a new package (app/design/frontend/[package]), and a new theme inside that package (app/design/frontend/[package]/[theme]), magento will fist look inside that theme folder for the layout updates and template files. If it doesn't find what it needs, it will search in the same package, but default theme (app/design/frontend/[package]/default). If the files are not there either it will search inside the base package, default theme (app/design/frontend/base/default).

So, the theme you are using uses a new package (instead of the default one), and your module files will never be found because it searches for them in the following order: app/design/frontend/flatastic/default app/design/frontend/base/default

The solution is simple. Move your files from default package to the base package. i.e:

app/design/frontend/default/default/layout/myextension.xml to app/design/frontend/base/default/layout/myextension.xml

and

app/design/frontend/default/default/myextension/mymodule/myincludes.phtml to app/design/frontend/base/default/myextension/mymodule/myincludes.phtml

  • I accepted this answer because it provided the clearer explanation and solution. I think it's more likely than the other correct answer to help someone in the future. – Matt Flamm May 27 '14 at 2:35
  • I have developed feedback form, code : dropbox.com/sh/32zqgejubfllz0h/AACkB_iIh-KJQxtEUikZ8i9Na?dl=0 Actually it is like static image on left side, how can i display into my all pages including home page. @Alex – Gem Oct 4 '18 at 8:42
1

Move your layout and template file in base/default instead of default/default.
base/default is the last level in the fallback. If your new theme is not inside the default package then it will not fallback to default/default but everything falls back to base/default.

  • this makes sense to me. Can I simply cut-paste the layout and template files to the same sub-folder in the base/default instead of default/default? Are any changes to the config files necessary? – Matt Flamm May 23 '14 at 15:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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