2011-09-06 15 views
3

我試圖通過空白主題中的customer.xml文件(這是在Magento 1.4中)向頂部客戶鏈接(我的帳戶,我的購物車等)添加一些解釋性文本.1.1)magento的customer.xml佈局文件中的其他參數

我認爲magento通過發佈afterText或beforeText參數具有開箱即用的功能,但是當我使用它們時,它似乎只是在鏈接之前推動了某些事情(而不是之後,這是我之後)。

這裏是從customer.xml包括額外< afterText>參數的摘錄:

<default> 
    <!-- Mage_Customer --> 
    <reference name="top.links"> 
     <action method="addLink" translate="label title" module="customer"><label>Your Account</label><url helper="customer/getAccountUrl"/><title>Your Account</title><prepare/><urlParams/><position>10</position><null /><aParams>rel="nofollow"</aParams><afterText>click to login</afterText></action> 
    </reference> 
</default> 

有沒有人有任何運氣這之前?它是否需要一些額外的liParams參數?

在此先感謝!

編輯:這是最終的代碼,似乎爲我工作。請注意,由於這個, 建議增加額外的字段,這對我們有很大的幫助。你和@Zyava回答下面幫助我解決它。 上面的建議(innerText字段)缺少一個字段。我已經將完整的代碼放在下面了,這對我來說很合適。希望它能幫助別人!

<action method="addLink" translate="label title" module="customer"> 
     <label>Your Account</label> 
     <url helper="customer/getAccountUrl"/> 
     <title>Your Account</title> 
     <prepare/> 
     <urlParams/> 
     <liParams/> 
     <aParams>rel="nofollow"</aParams> 
     <innerText/> 
     <beforeText>yourbeforetext</beforeText> 
     <afterText>youraftertext</afterText></action> 

非常感謝@clockworkgeek和@zyava--你們的答案都幫助我解決了這個問題。

回答

3

不幸的是,XML標籤名稱與變量參數無關,它是重要參數的數量。您需要指定最大爲afterText的所有參數,包括beforeText

<action method="addLink" translate="label title" module="customer"> 
    <label>Your Account</label> 
    <url helper="customer/getAccountUrl"/> 
    <title>Your Account</title> 
    <prepare/> 
    <urlParams/> 
    <position>10</position> 
    <liParams/> 
    <aParams>rel="nofollow"</aParams> 
    <beforeText/> 
    <afterText>click to login</afterText> 
</action> 
+0

謝謝clockworkgeek - 這個工作,它只需要添加 Andrew

+1

是否有這樣的原因?這看起來像是頭腦遲鈍。 –

+0

我想是因爲在它下面使用['call_user_func_array'](http://uk3.php.net/manual/en/function.call-user-func-array.php),它也與變量名稱不匹配,它只是關心條目的順序。否則就意味着需要額外的努力來做反射,當你只給出正確的參數數量時這是不必要的。 – clockworkgeek

1

Block'top.links'的類型爲Mage_Page_Block_Template_Links。看看Mage_Page_Block_Template_Links::addLink()方法:

public function addLink($label, $url='', $title='', $prepare=false, $urlParams=array(), 
    $position=null, $liParams=null, $aParams=null, $beforeText='', $afterText='') 
{ 

正如我們所看到的,$afterText參數存在這裏。現在轉到您的主題page/template/links.phtml,在我的情況下它是\app\design\frontend\base\default\template\page\template\links.phtml並檢查是否有類似<?php echo $_link->getAfterText() ?>的地方。

+0

謝謝zyava - 看着這個功能幫助發現了一個我沒有意識到的領域 - 現在開始工作。 – Andrew