8

I have a working link being added to the top.links block like this:

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

Eventually I wanted getAboutUsUrl to turn into getExternalSiteUrl. I want that one function to take parameters. For instance, getExternalSiteUrl('about-us') which would then return something like /the/url/about-us. However, I can't seem to find a way to send a helper class parameters in a Layout XML file. I searched for other modules doing this already, and couldn't find one in the Customer module where I searched.

Can anyone help?

Tyler V.
  • 2,471
  • 21
  • 44

1 Answers1

9
<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, therefore your method will need to explicitly define the getAboutUsUrl() method.

benmarks
  • 23,384
  • 1
  • 62
  • 84