2012-07-19 43 views

回答

1

我不確定你爲什麼想要這樣做,也許重新組織你的頁面結構將是一個更好的選擇 - 頁腳是頁腳而不是主要內容的一部分。

儘管如此,這可以很容易地使用layout xml來實現。

編輯

有兩種方法可以採用:

1.使用您的基地佈局將覆蓋本地XML文件。 - app/design/frontend/your_package/your_theme/layout/local.xml

這應該是你的首選方法,除非有針對你的特定用例的良好論點。

<?xml version="1.0"?> 
<layout> 
    <default> 
     <reference name="root"> 
      <action method="unsetChild"> 
       <alias>footer</alias> 
      </action> 
     </reference> 
     <reference name="content"> 
      <action method="insert"> 
       <alias>footer</alias> 
      </action> 
     </reference> 
    </default> 
</layout> 

或者......

2.複製基本佈局文件

副本app/design/frontend/base/default/layout/page.xmlapp/design/frontend/your_package/yout_theme/layout/page.xml

查找其聲明如下(在非觸摸頁面頁腳節點。 xml CE 1.7):

<block type="page/html_footer" name="footer" as="footer" template="page/html/footer.phtml"> 
    <block type="page/html_wrapper" name="bottom.container" as="bottomContainer" translate="label"> 
     <label>Page Footer</label> 
     <action method="setElementClass"><value>bottom-container</value></action> 
    </block> 
    <block type="page/switch" name="store_switcher" as="store_switcher" template="page/switch/stores.phtml"/> 
    <block type="page/template_links" name="footer_links" as="footer_links" template="page/template/links.phtml"/> 
</block> 

它將是根節點的直接後代。移動此整個節點,使其成爲主要內容的子節點:

<block type="core/text_list" name="content" as="content" translate="label"> 
    <label>Main Content Area</label> 

    <block type="page/html_footer" name="footer" as="footer" template="page/html/footer.phtml" after="> 
     <block type="page/html_wrapper" name="bottom.container" as="bottomContainer" translate="label"> 
      <label>Page Footer</label> 
      <action method="setElementClass"><value>bottom-container</value></action> 
     </block> 
     <block type="page/switch" name="store_switcher" as="store_switcher" template="page/switch/stores.phtml"/> 
     <block type="page/template_links" name="footer_links" as="footer_links" template="page/template/links.phtml"/> 
    </block> 
</block> 

記得刷新緩存如果啓用了:)

編輯

要回答的問題關於使用第二種方法的塊定位的評論。您可以使用前後屬性。

<block type="page/html_footer" name="footer" as="footer" template="page/html/footer.phtml" after="your_sibling_block_name"> 

還取決於其他佈局文件,你可能還需要編輯同級塊屬性之前添加到它即before="footer"

+0

是我已經做this.there有silder和產品部分主頁。因此頁腳部分顯示在它們之間。這意味着在滑塊後顯示頁腳部分,然後顯示產品部分。 – Kichu 2012-07-19 07:46:07

+0

好的,那麼您試圖讓頁腳出現在哪個塊名稱以及您使用了上述兩種方法中的哪一種? – 2012-07-19 07:49:51

+0

我使用的第二種方法 – Kichu 2012-07-19 08:16:51