开发者

additional parameters in magento's customer.xml layout file

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 i开发者_StackOverflows 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.


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>


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜