1

I've inserted a links block to the footer via local.xml:

    <reference name="footer">
        <block type="page/template_links" name="footer.social.links" as="footerSocialLinks">
            <action method="setTitle"><title>Finn oss på...</title></action>
            <action method="setName"><name>footer-social</name></action>
            <action method="addLink" translate="label title">
                <label><![CDATA[<em class="facebook"></em>Facebook]]></label>
                <url>https://www.facebook.com/xxxxx</url>
                <title>Besøk vår Facebook-side</title>
                <aParams>target="_blank"</aParams>
                <position>10</position>
                <prepare/>
            </action>
            <action method="addLink" translate="label title">
                <label><![CDATA[<em class="twitter"></em>Twitter]]></label>
                <url>https://twitter.com/xxxxx</url>
                <title>Følg oss på Twitter</title>
                <aParams>target="_blank"</aParams>
                <position>20</position>
                <prepare/>
            </action>
            <action method="addLink" translate="label title">
                <label><![CDATA[<em class="googleplus"></em>Google+]]></label>
                <url>https://plus.google.com/+xxxxx</url>
                <title>Besøk vår side på Google Plus</title>
                <aParams>target="_blank"</aParams>
                <position>30</position>
                <prepare/>
            </action>
            <action method="addLink" translate="label title">
                <label><![CDATA[<em class="youtube"></em>Youtube]]></label>
                <url>https://www.youtube.com/user/xxxxx</url>
                <title>Se på vår innhold på Youtube</title>
                <aParams>target="_blank"</aParams>
                <position>40</position>
                <prepare/>
            </action>
        </block>
    </reference>

This produces the following html:

<div class="links">
    <div class="block-title"><strong><span>Finn oss på...</span></strong></div>
    <ul id="footer-social">
        <li class="first"><a href="http://www.example.com/https:/www.facebook.com/" title="Besøk vår Facebook-side"><em class="facebook"></em>Facebook</a></li>
        <li><a href="http://www.example.com/https:/twitter.com/" title="Følg oss på Twitter"><em class="twitter"></em>Twitter</a></li>
        <li><a href="http://www.example.com/https:/plus.google.com/" title="Besøk vår side på Google Plus"><em class="googleplus"></em>Google+</a></li>
        <li class=" last"><a href="http://www.example.com/https:/index/www.youtube.com/user/xxxxx/" title="Se på vår innhold på Youtube"><em class="youtube"></em>Youtube</a></li>
    </ul>
</div>

The main problems here are that the urls are horribly malformed and the aParams missing. I don't know where or what magento has done to the urls; in the first 3 cases the user part of the link is missing, and in the 4th link (youtube) there is a mysterious "index" added.

I have tried to wrap the url with CDATA, I've tried removing the empty tag, to no avail. The block code and template provide very few hints.

Maybe I'm just wasting time trying to do something "properly" when I could just include a static block. Meh!

2 Answers 2

3

Looking at the signature of the addLink method in Mage_Page_Block_Template_Links class

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

the ordering of your parameters is wrong. Try reordering them like so:

<action method="addLink" translate="label title">
    <label><![CDATA[<em class="googleplus"></em>Google+]]></label>
    <url>https://plus.google.com/+xxxxx</url>
    <title>Besøk vår side på Google Plus</title>
    <prepare/>
    <urlParams/>
    <position>30</position>
    <liParams/>
    <aParams>target="_blank"</aParams>
</action>
1
  • Thank you! I hadn't realised the order of parameters had to match the method signature; I wish I'd known that a long time ago. It also turns out that since I'd mixed up the <aParams> and <prepare> parameters, <prepare> was probably using the value of <aParams> (a string) and cast as true, hence the screwed up links. Ah! Understanding is bliss.
    – Turpachull
    Commented Feb 13, 2015 at 8:47
1

Funny thing is, the name of the nodes does not matter. Only the order counts and you have to have them all.

This code works too:

<action method="addLink" translate="label title">
            <label><![CDATA[<em class="facebook"></em>Facebook]]></label>
            <url>http://www.facebook.com/xxxxx</url> 
            <title>Besøk vår Facebook-side</title>
            <prepgfdgfdare/>
            <urlPagfdgfdgfdrams/> 
            <position>10</position>
            <liPgfdgfdgfdarams/>
            <aParagfdgfdgfdms>target="_blank"</aParagfdgfdgfdms>
            <beforeTegfdgfdxt></beforeTegfdgfdxt>
            <afterText></afterText>
        </action>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.