2013-10-04 66 views
1

我是Magento主題的新手,並且正在嘗試做一些基本的主題更改。如何將Magento top.links複製到頁眉和頁腳

我想在我的頁眉和頁腳中顯示相同的top.links菜單。

我加了塊頁腳中page.xml:

<block type="page/html_footer" name="footer" as="footer" template="page/html/footer.phtml"> 
<block type="page/template_links" name="top.links" as="topLinks"/> 

,並添加以下代碼到footer.phtml

<?php echo $this->getChildHtml('topLinks') ?> 

這樣的菜單在頁腳顯示出來後,但不再在標題中。我猜一個塊只能顯示一次?我如何在頁眉和頁腳上顯示它?

謝謝。

+0

您可以在不使用xml的情況下調用它。只需在頁腳頁面中調用<?php echo $ this-> getChildHtml('topLinks')?>。 –

+0

@ K-THIHA - 我嘗試過,但沒有奏效。只是在DIV內沒有任何東西。 – user2766838

回答

-1

我認爲你不需要塊拷貝在XML中,如果你只是複製頁腳文件中的代碼,將工作

+0

不行,它不起作用 – OSdave

0

在佈局page.xml文件:

 <block type="page/html_footer" name="footer" as="footer" template="page/html/footer.phtml"> 
      <block type="page/template_links" name="footer.links" as="footerLinks"> 
       //you need to add the links you wanna show here, for example: 
       <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> 
       //search for 'addLink' in the layout xml files to find all the links you want 
      </block> 
      ...//rest of footer's content 
     </block> 

,並在您footer.phtml:

<?php echo $this->getChildHtml('footerLinks') ?>