Add custom variable to cms block in magento


Cms content :: Hello {{variable1}},

Thanks we will contact you.

Thanks
[‘variable2’]

Make This function in any of your helper file.

public function getFilterContent($html = '')
	{
	
		if($html != ''){
			$array = array();
			$array['variable1'] = 'customername';
			$array['variable2'] = 'Team'; /* you can set any no of variable like this */
	 
			// loading the filter which will get the array we created and parse the block content
			$filter = Mage::getModel('cms/template_filter');
			/* @var $filter Mage_Cms_Model_Template_Filter */
			$filter->setVariables($array);
	 
			// return the filtered block content.
			return $filter->filter($html);
		}else{
			return;
		}
	}
}
Advertisements