2012-09-09 41 views
0

我想改變一些塊的順序和位置。從標題到右側的放置已經改變,但訂單塊不起作用。Magento重新安排塊不工作

這裏是我的代碼:

<reference name="header"> 
    <action method="unsetChild"><name>top.menu</name></action> 
    <action method="unsetChild"><name>top.search</name></action> 
    <action method="unsetChild"><name>top.links</name></action> 
</reference> 

<reference name="right"> 
    <remove name="right.poll" /> 

    <action method="insert"> 
     <blockName>top.menu</blockName> 
    </action> 

    <action method="insert"> 
     <blockName>top.search</blockName> 
    </action> 

    <action method="insert"> 
     <blockName>top.links</blockName> 
     <after>top.menu</after> <!-- Here I want top.links to come after top.menuwhich is not working --> 
    </action> 
</reference> 
+0

你是什麼意思安置與秩序? – jjm

+0

@jjm,Placement意味着將位置從'header'改爲'right',它正在工作。但是我想在'top.menu'之後想要'top.links'這個塊的順序不起作用 – mrN

+0

Ivan給出了一個很好的答案,涵蓋了你要找的東西http://stackoverflow.com/questions/4410206/通過本地xml-file-in-magento改變塊的順序 – McNab

回答

2

這裏,<after>是一個布爾值,你可以不寫塊的名字裏面。

<action method="insert"> 
     <blockName>top.links</blockName> 
     <after>top.menu</after> <!-- Here I want top.links to come after top.menuwhich is not working --> 
</action> 

試試這個:

<action method="insert"> 
     <blockName>top.links</blockName> 
     <sublingName>top.menu</sublingName> 
     <after>1</after> 
</action> 
+0

有沒有一個捷徑來完成這件事? – mrN

+1

@mrN對不起你說的是什麼意思? – Kalpesh

+0

我的意思是類似' mrN

0

另一種辦法是通過

  1. 從一個乾淨的基礎開始刪除塊
  2. 重建他們

這是我堅持的onnally更喜歡,因此,完整的佈局更新在local.xml中,然後更易於閱讀和理解維護。這也可以避免塊嵌套衝突,因爲我的解決方案提議重新命名它們(top.links => right.links,top.search => right.search,top.nav => right.nav)。但是,這只是我的看法基於我的經驗:)

From top to right

所以這裏是我已經成功地試了Magento的的local.xml中1.7.0.1

<layout version="0.1.0"> 
    <default> 
     <reference name="header"> 
      <remove name="top.menu"/> 
      <remove name="top.search"/> 
      <remove name="top.links"/> 
     </reference> 

     <reference name="right"> 

      <block type="core/text_list" name="right.menu" as="topMenu" translate="label" before="-"> 
       <label>Navigation Bar</label> 
       <block type="page/html_topmenu" name="catalog.rightnav" template="page/html/topmenu.phtml"/> 
      </block> 

      <block type="page/template_links" name="right.links" as="rightLinks" after="right.menu"> 
       <action method="addLink" translate="label title" module="customer"><label>My Account</label><url helper="customer/getAccountUrl"/><title>My Account</title><prepare/><urlParams/><position>10</position></action> 

       <block type="wishlist/links" name="wishlist_link" /> 
       <action method="addLinkBlock"><blockName>wishlist_link</blockName></action> 

       <block type="checkout/links" name="checkout_cart_link"> 
        <action method="addCartLink"></action> 
        <action method="addCheckoutLink"></action> 
       </block> 
      </block> 

      <block type="core/template" name="right.search" as="rightSearch" template="catalogsearch/form.mini.phtml" after="right.links"/> 

     </reference> 
    </default> 

    <customer_logged_in> 
     <reference name="right.links"> 
      <action method="addLink" translate="label title" module="customer"><label>Log Out</label><url helper="customer/getLogoutUrl"/><title>Log Out</title><prepare/><urlParams/><position>100</position></action> 
     </reference> 
    </customer_logged_in> 

    <customer_logged_out> 
     <reference name="right.links"> 
      <action method="addLink" translate="label title" module="customer"><label>Log In</label><url helper="customer/getLoginUrl"/><title>Log In</title><prepare/><urlParams/><position>100</position></action> 
     </reference> 
    </customer_logged_out> 
</layout>