2010-05-11 66 views
1

我一直在編輯Magento的默認CSS來改變外觀,並且已經到了我想要移動某些內容塊的地步。Magento - 如何將導航塊移動到右欄中?

我已經通過CSS

.col-left { display: none; } 

殺死了左側立柱後上升的主要內容部分的寬度,以創建「兩個欄佈局」。我現在想要做的是將類別的導航移動到右欄。我只是不知道如何...

如何在Magento中移動內容塊? :/

回答

3

通過修改佈局XML文件,而不是通過CSS進行黑客攻擊,可以很好地完成像Magento這樣的大動作。在文件catalog.xml,這裏有相關線路:

<reference name="top.menu"> 
     <block type="catalog/navigation" name="catalog.topnav" template="catalog/navigation/top.phtml"/> 
    </reference> 
    <reference name="left"> 
     <!--<block type="core/template" name="left.permanent.callout" template="callouts/left_col.phtml"> 
      <action method="setImgSrc"><src>images/media/col_left_callout.jpg</src></action> 
      <action method="setImgAlt" translate="alt" module="catalog"><alt>Our customer service is available 24/7. Call us at (555) 555-0123.</alt></action> 
      <action method="setLinkUrl"><url>checkout/cart</url></action> 
     </block>--> 
    </reference> 
    <reference name="right"> 
     <!--<block type="core/template" before="cart_sidebar" name="catalog.compare.sidebar" template="catalog/product/compare/sidebar.phtml"/>--> 
     <!--<block type="core/template" name="right.permanent.callout" template="callouts/right_col.phtml"/>--> 
    </reference> 

要渲染topnav,動議catalog/navigation線到左或右列塊和導航將呈現爲這樣的。

希望有幫助!

謝謝, 喬

2

Magento的有四 「標準」 佈局:1col,3col,2col左和2col右,但可以添加,如果您想了解更多。你會想要改變你編輯的頁面上使用的佈局,而不是使用CSS。這絕對是錯誤的做法。

作爲約瑟夫指出的,Magento的模板系統是由,或模板,其通過佈局文件定位。模板是標準的php,但前綴爲.phtml,佈局爲xml。您將在app/design/frontend/$interface/$theme/(template|layout)中找到大量這些文件。

Magento因其糟糕的文檔而聲名顯赫,但您可能想要檢出他們的Designer's Guide,其中詳細介紹了模板和佈局的概念,包括如何移動塊。

佈局文件的語法遠非直截了當,但現在您所需要知道的大部分內容都是爲了引用右側的塊,左側和內容列可以看出爲:

<reference name="(right|left|content)"></reference> 

移動<block />聲明從一個到另一個原因塊移動。

另一個關鍵一個要記住的是看出來:

<reference name="root"> 
    <action method="setTemplate"><template>page/1column.phtml</template></action> 
</reference> 

使用setTemplate動作引用根容器可以讓你的模板切換到1column2columns-left2columns-right3columns時容易。佈局模板本身可以在template/page/中找到。