Passing a Helper Class Parameter Using an XML Layout File

I have a working link that is added to the top.links block as follows:

<block type="page/template_links" name="top.links" as="topLinks"> <action method="addLink"> <label>About Us</label> <url helper="mymodule/getAboutUsUrl"/> <title>About Us</title> <prepare/> <urlParams/> <position>20</position> </action> </block> 

In the end, I wanted getAboutUsUrl to turn into getExternalSiteUrl. I want one function to take parameters. For example, getExternalSiteUrl ('about-us'), which will then return something like / the / url / about -us. However, I cannot find a way to send helper class parameters to the Layout XML file. I was looking for other modules that had already done this, and could not find it in the Customer module where I was looking.

Can anyone help?

+6
source share
1 answer
 <block type="page/template_links" name="top.links" as="topLinks"> <action method="addLink"> <label>About Us</label> <url helper="mymodule/getAboutUsUrl"> <arg>Now with more args!</arg> <!-- will result in the string being passed as first arg --> </url> <title>About Us</title> <prepare/> <urlParams/> <position>20</position> </action> </block> 

Note that helpers do not extend Varien_Object , so your method will have to explicitly define the getAboutUsUrl() method.

+7
source

All Articles