1

I've created a two custom structural blocks. Both blocks are sidebars that are used for navigation, cart, authentication etc. Each structural block has its own core/template block which acts as a wrapper for the content.

<reference name="root">
     <block type="core/text_list" name="sidebar.left" as="sidebar-left" translate="label">
        <label>Mobile_Nav</label>
     </block>
     <block type="core/text_list" name="sidebar.right" as="sidebar-right" translate="label">
        <label>Sidebar</label>
     </block>
</reference>

Both blocks work fine, and I've added multiple customs and non default blocks to them. However, I fail at loading a custom block responsible for login/authentication. I can however load this block in the content block.

<reference name="sidebar.right">
    <block type="core/template" name="sidebar.right.content" template="page/html/sidebar-right.phtml">
         <block type="checkout/cart_sidebar" name="cart_sidebar" as="sidebar.cart" template="checkout/cart/sidebar.phtml"/>
         <block type="ajaxauthentication/sidebar" name="authentication_sidebar" as="authentication" template="ajaxauthentication/welcome.phtml" />
         <action method="setChild"><child>"authentication_sidebar"</child><alias>authentication</alias></action>
    </block>
</reference>

I suspect it has something to do with that the structural block does not yet exist when I call the ajaxauthentication block. However, I am neither sure nor clueless how to solve it.

1 Answer 1

1

Yes, you can only reference blocks that have been created before. Layout handles are processed in a certain order and without knowing in which files and under which handles you are creating and referencing the block I cannot give you a solution, just explain how it works:

  • the <default> layout handle is always processed before page specific layout handles
  • the directives within one handle in a single file are processed from top to bottom
  • files from all modules are merged first, in the order the modules are loaded.

So, if your codes are both in the <default> handle, but in different modules, so you have to make sure, the first one is loaded first.

Module loading order is determined as follows:

  1. A dependency graph is built from <depends> definitions in app/etc/modules/*.xml. If X depends on Y, Y is loaded before X.

  2. After ordering by dependency, core modules have precedence over community and local modules

  3. Everything else is loaded alphabetically. Note that the file name in app/etc/modules is used for comparison, not the actual module name.

So you have two options to influence module loading order:

  1. make the second one ´` on the first
  2. Rename the module definition files in app/etc/modules. You don't need to rename the module itself because the filename does not matter for anything else than loading order.

("3. add your module to the core code pool" does not count)

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.