Jump to content

Get custom field in html format


Recommended Posts

I use a easy module for add custom field tab in product, the problem is that field in mysql contain html but in theme file the html is stripped, this is code that get field value

	public function hookProductTabContent($params)
    {
        global $smarty;
		$id_product = (int)Tools::getValue('id_product');
		$id_lang = Context::getContext()->language->id;
		
        //Transfer the new tab content into template via smatry
        //( it is optional as far as the content can be assigned directly in the template)
		
		$result = Db::getInstance()->ExecuteS('SELECT custom_field, id_lang FROM '._DB_PREFIX_.'product_lang WHERE id_lang= '.$id_lang.' AND  id_product = ' . (int)$id_product);
		if(!$result)
			return array();

		foreach ($result as $field) {
			$content = $field['custom_field'];
			break;
		}
        $smarty->assign('productcare', $content);
        // Call the template containing the HTML-code of our new tab content:
        //return $this->display(__FILE__ , 'tpl/productTabContent.tpl');
    }

Link to comment
Share on other sites

Prestashop version? The use of globals is deprecated.
Also the foreach doesn't make much sense since it only gets the content of a single entry in the results array. I also never saw a break inside foreach, I admit, what's the purpose of it supposed to be?
Are you 100% sure the value is not stripped in the database already? How are you outputting to the template?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...