additional parameters in magento's customer.xml layout file

陌路散爱 提交于 2019-12-22 10:08:38

问题


i'm trying to add some explanatory text to the top customer links (my account, my cart etc) via the customer.xml file from the blank theme (this is in Magento 1.4.1.1)

i think that magento has the capability out of the box by issuing afterText or beforeText parameters, but when i use them it only seems to shove things before the link (not after, which is what I'm after).

here's an extract from customer.xml that includes the additional < afterText > parameter:

<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>

has anyone had any luck with this before? does it need some additional arguments for liParams?

thanks in advance!

EDIT: here's the final code that seems to be working for me. Note the addition of the extra fields as suggested by thanks for this, it helped a lot. both you and @Zyava answer below helped me sort it out. There's one field missing from your suggestion above (the innerText field). I've put the full code below that looks to be working for me. hope it helps someone else!

    <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>

big thank you to @clockworkgeek and @zyava - both of your answers helped me get through this.


回答1:


Unfortunately the XML tag names don't relate to the variable parameters, it is the number of parameters that matters. You need to specify all parameters up to afterText including 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>



回答2:


Block 'top.links' has type Mage_Page_Block_Template_Links. Look at Mage_Page_Block_Template_Links::addLink() method:

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

As we can see, $afterText parameter exists here. Now go to your theme's page/template/links.phtml, in my case it is \app\design\frontend\base\default\template\page\template\links.phtml and check that something like <?php echo $_link->getAfterText() ?> is present there.



来源:https://stackoverflow.com/questions/7321364/additional-parameters-in-magentos-customer-xml-layout-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!