Jump to content
rtyrtrty

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

Recommended Posts

How to send a variable from the module with html tags? I pass the variable, and it shows <p></p>.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

You you are right. Thank you. I use in module - Tools::htmlentitiesUTF8(), and how right to decode in *.tpl?

Edited by ken5

Share this post


Link to post
Share on other sites

You can use the same function as in your PHP files, the syntax will only change, nothing else.
 

{$decoded_var = Tools::htmlentitiesDecodeUTF8($variable)}

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

How to get configuration value of custom module to tpl file in theme directory?

Share this post


Link to post
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

×

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More