Try the Demo

Magento Forum

   
action method addLink add query string to url
 
Frederik Krautwald
Member
 
Avatar
Total Posts:  56
Joined:  2007-09-25
Reykjavík, Iceland
 

I have searched the forum thin and tried suggestions, but somehow I can´t find any info on how to a query string to a link using <action method="addLink"/>

I have found this info for the build-up:

<action method="addLink" translate="label title" module="checkout">
    <
label>Checkout</label>
    <
url>checkout</url>
    <
title>Checkout</title>
    <
prepare>true</prepare>
    <
urlParams/>
    <
position>60</position>
    <
li/>
    <
a>class="top-link-checkout"</a>
</
action>

But if I add the query string, say ?___store=default at the end of the content in the <url> tag, the html output looks like this http://mydomain.tld/checkout?___store=default/. Notice the added slash in the end prevents it from working.

I then experimented with the <urlParams> tag, which also lacks total documentation and no forum posts describing the usage of it. So, I tried to add it like this:

<urlParams>
    <
store>default</store>
</
urlParams>

which outputs http://mydomain.tld/checkout/index/index/store/default/. Again, tough luck!!!

Does anyone know how to overcome this? Thanks!

 Signature 

Icelandic Web Design and Web hosting

 
Magento Community Magento Community
Magento Community
Magento Community
 
Guy Park
Jr. Member
 
Total Posts:  13
Joined:  2009-04-16
 

Hi Frikki,

I’ve worked this out so far with the addLink action.  Hope it helps.
With your current setup, try turning <prepare>true</prepare> to just <prepare/>, and try the URL as <url>/checkout?___store=default</url>, or what ever the extension.

<action method="addLink" translate="label title" module="checkout">
    <
label>Checkout</label>
    <
url>/checkout?___store=default</url>
    <
title>Checkout</title>
    <
prepare/>
    <
urlParams/>
    <
position>60</position>
    <
li/>
    <
a>class="top-link-checkout"</a>
</
action>

I had issues with the < prepare>(true|false)</prepare> just keep changing my URLS to relative, including http://www.domain.tld/ type urls. 

I found that by changing it to just < prepare /> (ignore the spaces), it solved my issue of Magento rewriting my URL’s.

Let me know how that goes…

 
Magento Community Magento Community
Magento Community
Magento Community
 
Frederik Krautwald
Member
 
Avatar
Total Posts:  56
Joined:  2007-09-25
Reykjavík, Iceland
 

Thanks for the info. Very much appreciated. I did, somehow, get around it in the project that had issue (but can’t exactly remember what I did). Anyway, this is definitely useful information you have provided. Thank you.

 Signature 

Icelandic Web Design and Web hosting

 
Magento Community Magento Community
Magento Community
Magento Community
 
kelvin
Jr. Member
 
Total Posts:  15
Joined:  2008-06-11
 

Sorry for bumping this old thread but I figured someone will find this useful.

I had the same issue and doing the above didn’t work for me.

I finally figured it out so if you had the same problem hopefully this will save you a good few hours.

The syntax for adding in a querystring to the URL for the action XML is this:

<action method="addLink" translate="label" module="customer"><name>account_myurl</name><url>myurl</url><label>My URL</label><params><_query>filtered=user</_query></params></action>

I pretty much guessed the tags for the params bit.

This is for Magento CE 1.6.1 btw.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Billzy
Jr. Member
 
Total Posts:  2
Joined:  2009-08-31
 

I am using 1.7.0.2 and managed to get this working with the following into your themes layout/page.xml;

<block type="page/template_links" name="top.links" as="topLinks">                   
                    <
action method="addLink" translate="label title">
                        <
label></label>
                        <
url></url
                        <
title>Home</title>
                        <
prepare>true</prepare>
                        <
urlParams helper="core/url/getHomeUrl"/> 
                        <
position>1</position>
                        <
liParams/>
                        <
aParams>class="top-link-home"</aParams>
                        <
beforeText></beforeText>
                        <
afterText></afterText>
                    </
action>                    
                    <
action method="addLink" translate="label title">
                        <
label></label>
                        <
url>checkout/cart</url
                        <
title>View Cart</title>
                        <
prepare>true</prepare>
                        <
urlParams helper="core/url/getHomeUrl"/> 
                        <
position>4</position>
                        <
liParams/>
                        <
aParams>class="top-link-cart"</aParams>
                        <
beforeText></beforeText>
                        <
afterText></afterText>
                    </
action>
                    <
action method="addLink" translate="label title">
                        <
label></label>
                        <
url>checkout</url
                        <
title>Checkout Now!</title>
                        <
prepare>true</prepare>
                        <
urlParams helper="core/url/getHomeUrl"/> 
                        <
position>5</position>
                        <
liParams/>
                        <
aParams>class="top-link-checkout"</aParams>
                        <
beforeText></beforeText>
                        <
afterText></afterText>
                    </
action>                                        
                
                </
block>

.etc Hope this helps someone ... P.S to change text just use the Label.  I have no labels because I am using CSS icons.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top