2

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

3

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.

  • Thanks for your reply, I tried using: module_namespace/helperMethod and Magento is adding Mage_ in front of my Helper class name. What am I missing? – J Plana Dec 10 '15 at 18:36
  • I was using the wrong helper path. I changed to modulename/helperMethod and it worked perfectly. Thanks for your help! – J Plana Dec 10 '15 at 18:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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