How to Get Base URL in a Layout XML File in Magento 1.9

layoutmagento-1.9template

I'm using Magento 1.9 and in app/design/frontend/mytheme/mytheme/layout/page.xml I got the following code snippet:

<reference name="head">
<block type="core/text" name="stylescss">
    <action method="setText">
        <css><![CDATA[<link rel="stylesheet" type="text/css" href="https://www.example.com/css/styles.css?v=1.0" media="all" />]]></css>
    </action>
</block>

This was done originally in order to be able to control the version of the stylesheet, and bypass several layers of caching, forcing the user browser to fetch a different version of the file.

Is there a way to replace www.example.com for a variable containing the baseurl?

P.S. Any alternative solution to add versioning to a file, is more than welcome 🙂

Thank you

Best Answer

You could use use helper method.

<reference name="head">
    <block type="core/text" name="stylescss">
        <action method="setText">
            <css helper="your_module/someHelperMethod" />
    </action>
</block>

And then, in your module helper file, create method, which return string with base url.

Related Topic