Jump to content

How to send a variable from the module with html tags?


KenFranklin

Recommended Posts


If you want to send html values into the tpl file then you will have to encode the value first and decode it on tpl file.

 

Encode with - Tools::htmlentitiesUTF8()

 

Decode with - Tools::htmlentitiesDecodeUTF8()

 

 

 

Example - Let's say have some html content in a variable $var.

 

Then you will have to encode it first-: $var_to_assign = Tools::htmlentitiesUTF8($var);

 

Assign it to a tpl file like this -: $this->context->smarty->assign('var', $var_to_assign);

 

Get and decode the value in tpl file -: {$html_content = Tools::htmlentitiesDecodeUTF8($var)}

 

 

 

If it does not work you can also try this in the tpl file -: {$var nofilter}

Edited by Knowband Plugins (see edit history)
Link to comment
Share on other sites

I make this variant.

'copyright_text' => Tools::htmlentitiesUTF8(Configuration::get('copyright_text', $this->context->language->id))
{if isset($settings.copyright_text) && $settings.copyright_text}
  {Tools::htmlentitiesDecodeUTF8($settings.copyright_text)}
{/if}

Not work tags for example <strong></strong>

Edited by ken5 (see edit history)
Link to comment
Share on other sites

  • 1 year later...

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...