2012-11-07 105 views
0

我正在爲magento中的供應商創建模塊。我想供應商登錄鏈接在top.links.在Magento中爲自定義模塊添加鏈接

如何添加鏈接?

此外,有誰能夠告訴我,像<customer_logged_out><customer_logged_in>標籤的含義在magento/app/design/frontend/base/default/layout/customer.xml

東陽我

magento/app/design/frontend/default/default/layout/supplier.xml使用<supplier_logged_in><supplier_logged_out>它不工作。

這是示例代碼從我的文件

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

而且是有<customer_logged_in>文件,以它的工作的內容?

回答

1

這裏是你如何添加里面的頂部鏈接自定義鏈接,更多信息可以在這裏找到http://www.classyllama.com/development/magento-development/editing-magentos-top-links-the-better-way

<reference name="top.links"> 
        <!-- Add custom links. Pretty self-explanatory. 
        Dig into app/code/core/Mage/Page/Block/Template/Links.php for more info --> 
        <action method="addLink" translate="label title"> 
         <label>About Us</label> 
         <url>about</url> <!-- can use full url also --> 
         <title>About Us</title> 
         <prepare>true</prepare> <!-- set true if adding base url param --> 
         <urlParams helper="core/url/getHomeUrl"/> <!-- base url - thanks @Russ! --> 
         <!-- there are a few param you can send to do different things in <urlParams> 
           dig into app/code/core/Mage/Core/Model/Url.php, around line 803 -->     

         <!-- below adds #add-fragment to the end of your url --> 
         <!-- <urlParams><_fragment>add-fragment</_fragment></urlParams> --> 

         <!-- below adds ?add-query to the end of your url --> 
         <!-- <urlParams><_query>add-fragment</_query></urlParams> --> 

         <!-- below gives you a new session id (i think...)--> 
         <!-- <urlParams><_nosid>true</_nosid></urlParams> --> 

         <!-- below replaces double quotes, single quotes, greater than, and less than signs 
           to their respective url escaped replacements (%22, %27, %3E, %3C) --> 
         <!-- <urlParams><_escape>i'm-a-blog-url</_escape></urlParams> --> 

         <position>1</position> 
         <liParams/> 
         <aParams>class="top-link-about-us"</aParams> 
         <beforeText></beforeText> 
         <afterText></afterText> 
        </action> 
    </reference> 

您需要添加上面的代碼在任何<default>節點或內部<customer_logged_out><customer_logged_in>(這兩個Magento用於在客戶登錄或註銷商店時添加功能的句柄)。

//app/core/Mage/Core/Model/Layout/Update.php. 
class Mage_Customer_Model_Observer 
{ 
    public function beforeLoadLayout($observer) 
    { 
     $loggedIn = Mage::getSingleton('customer/session')->isLoggedIn(); 

     $observer->getEvent()->getLayout()->getUpdate() 
      ->addHandle('customer_logged_'.($loggedIn?'in':'out')); 
    } 
} 

<supplier_logged_in>(如果需要),您的擴展,你需要首先你的Magento自定義擴展裏面添加自定義佈局手柄內使用。開始挖它,我會推薦以下相關文章:

http://magebase.com/magento-tutorials/creating-custom-layout-handles/

http://www.classyllama.com/magento/add-custom-layout-handles-e-g-parent-categories

相關問題