View previous topic :: View next topic |
Author |
Message |
Weedoze Smarty n00b
Joined: 18 Jan 2017 Posts: 4
|
Posted: Wed Jan 18, 2017 2:18 pm Post subject: $escape_html not working |
|
|
i would like to set $escape_html to TRUE but I can't find how.
My smarty initialization :
Code: | self::$smarty = new Smarty();
self::$smarty->template_dir = '../templates'; |
I tried to set it like this
Code: | self::$smarty->escape_html = true; |
But this is not working.
What did I miss ? |
|
Back to top |
|
bsmither Smarty Elite
Joined: 20 Dec 2011 Posts: 322 Location: West Coast
|
Posted: Wed Jan 18, 2017 11:31 pm Post subject: |
|
|
Please confirm the programming requirement that you load the instance of Smarty into 'self::$smarty'.
'self::' implies this is inside some kind of class object.
I don't know if that is good or bad. But if it works...
I also see in the docs that the boolean is in upper case. Try it that way.
You can also try the magic setter way: Code: |
self::$smarty->setEscapeHtml(true); // or maybe TRUE |
|
|
Back to top |
|
Weedoze Smarty n00b
Joined: 18 Jan 2017 Posts: 4
|
Posted: Thu Jan 19, 2017 7:52 am Post subject: |
|
|
I am loading Smarty into self::$smarty
I tried
Code: | self::$smarty->setEscapeHtml(true); |
But it makes my site crash
I also tried with but still not working |
|
Back to top |
|
bsmither Smarty Elite
Joined: 20 Dec 2011 Posts: 322 Location: West Coast
|
Posted: Thu Jan 19, 2017 4:18 pm Post subject: |
|
|
Please confirm the version of Smarty being used.
The docs for Smarty 2 make no mention of $escape_html, nor any mention of the magic setter method (which caused your page to crash).
This may be a Smarty 3 capability. |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Sun Jan 22, 2017 8:48 am Post subject: |
|
|
"It doesn't work" is a ridiculous statememnt.
It conveys essentially no information.
Please provide code examples and result samples demonstrating your issue. |
|
Back to top |
|
Weedoze Smarty n00b
Joined: 18 Jan 2017 Posts: 4
|
Posted: Wed Mar 08, 2017 7:58 am Post subject: |
|
|
Thank you for all your replies.
The problem was finally that I was working with Smarty 2. I upgraded to version 3 and it is now working.
It is even working a little bit too much.
I have my index.tpl that contain the main layout and has inside to display the page needed.
My problem is that all the page will be now escaped because of .
How can I enable escape_html for the children of this page only ? Not the page itself ?
I already tried to use {$body nofilter} but then it is also used for the children templates |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Wed Mar 08, 2017 4:45 pm Post subject: |
|
|
Reverse your inheritance pattern, use extend rather than include.
Or only use include, don't pre-render your HTML in PHP code. |
|
Back to top |
|
Weedoze Smarty n00b
Joined: 18 Jan 2017 Posts: 4
|
Posted: Mon Mar 13, 2017 7:07 am Post subject: |
|
|
Thank for the answer. Could you please elaborate ? I am totally new with Smarty. Could you give me an example ?
Thank you |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Mon Mar 13, 2017 5:52 pm Post subject: |
|
|
Read entire documentation.
Or pay me to retype it here for you. |
|
Back to top |
|
|