Chudz
Chudz

Reputation: 160

Magento Block Positioning Never Works

Hello I always seem to have problems positions blocks.

Please see the website I am working on: http://www.hemptationz.com

I want the blocks on the left sidebar to appear in this order:

Facebook Block (callouts/facebook.pthml) Currency Block (directory/currency.phtml) Product Categories Block (vertnav/left.phtml) Information Links Block (callouts/left_col.phtml)

This is the code I have in the XML layout files:

Catalog.xml

<reference name="left">
  <block type="core/template" name="facebook" template="callouts/facebook.phtml" after="currency" />
  <block type="core/template" name="left.permanent.callout" template="callouts/left_col.phtml" after="catalog.vertnav" />
</reference>

vertnav.xml

<reference name="left">
  <block type="vertnav/navigation" name="catalog.vertnav" template="vertnav/left.phtml" before="left.permanent.callout" />
</reference>

directory.xml

<layout version="0.1.0">

<!--
Category default layout
-->
    <default>
        <reference name="head">
            <block type="core/template" name="optional_zip_countries" as="optional_zip_countries" template="directory/js/optional_zip_countries.phtml" />
        </reference>
    </default>

    <catalog_category_default>
        <reference name="left">
            <block type="directory/currency" name="currency" before="facebook" template="directory/currency.phtml"/>
        </reference>
    </catalog_category_default>

<!--
Category layered navigation layout
-->

    <catalog_category_layered>
        <reference name="left">
            <block type="directory/currency" name="currency" before="facebook" template="directory/currency.phtml"/>
        </reference>
    </catalog_category_layered>

<!--
Catalog Search layout
-->

    <catalogsearch_advanced_index>
        <reference name="left">
            <block type="directory/currency" name="right_currency" before="facebook" template="directory/currency.phtml"/>
        </reference>
    </catalogsearch_advanced_index>

    <catalogsearch_result_index>
        <reference name="left">
            <block type="directory/currency" name="currency" before="facebook" template="directory/currency.phtml"/>
        </reference>
    </catalogsearch_result_index>

    <catalogsearch_advanced_result>
        <reference name="right">
            <block type="directory/currency" name="right_currency" before="facebook" template="directory/currency.phtml"/>
        </reference>
    </catalogsearch_advanced_result>

</layout>

Thanks hope you can help me.

Upvotes: 1

Views: 1806

Answers (2)

zokibtmkd
zokibtmkd

Reputation: 2183

You want this order: 1. Facebook 2. Currency 3. Vertical Navigation 4. Information Links but in your layout you have specified that facebook is after currency. If you want something to show first you have to use before="-" (in facebook link), then use after="facebook" for currency, after="currency" for catalog.vertnav and use after="-" for left.permanent.callout to position it on the bottom.

Upvotes: 0

Alana Storm
Alana Storm

Reputation: 166046

The before and after attributes are limited in scope. They can only influence

The order of blocks within a particular sub-block when that sub-block is a core/test_list or other block that automatically renders sorted children.

You've not given enough context around how you're using the attributes in your question to give you specific advice, but I don't think you can do what you think you can with the feature. Be more explicit in your question and provide code example, along with "I expected foo, I got bar" style context, and will help you.

Upvotes: 2

Related Questions