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

2 comments on “Add custom variable to cms block in magento

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s