Use dynamic data in magento theme layout xml


If you need to use any dynamic text with php conditon in magento theme layout, you can use your module helper functions there. For example here, am just declaring the media url in the script variable from php file.

In themelayout.xml

   <reference name="head">
      <block type="core/text" name="module.js">
          <action method="setText"><text helper="modulename/baseurljs"/></action>

In helper file

   public function baseurljs()
		$script =  "<script>var baseSecureUrl = '".Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA); </script>";
		return $script;

Clear all your cache. Check in view source you can get media url in the script. Have a great day!!

One thought on “Use dynamic data in magento theme layout xml

Leave a Reply

Your email address will not be published. Required fields are marked *