Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

$escape_html not working

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
Weedoze
Smarty n00b


Joined: 18 Jan 2017
Posts: 4

PostPosted: Wed Jan 18, 2017 2:18 pm    Post subject: $escape_html not working Reply with quote

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
View user's profile Send private message
bsmither
Smarty Elite


Joined: 20 Dec 2011
Posts: 322
Location: West Coast

PostPosted: Wed Jan 18, 2017 11:31 pm    Post subject: Reply with quote

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
View user's profile Send private message
Weedoze
Smarty n00b


Joined: 18 Jan 2017
Posts: 4

PostPosted: Thu Jan 19, 2017 7:52 am    Post subject: Reply with quote

I am loading Smarty into self::$smarty

I tried

Code:
self::$smarty->setEscapeHtml(true);


But it makes my site crash

I also tried with
Code:
=TRUE
but still not working
Back to top
View user's profile Send private message
bsmither
Smarty Elite


Joined: 20 Dec 2011
Posts: 322
Location: West Coast

PostPosted: Thu Jan 19, 2017 4:18 pm    Post subject: Reply with quote

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
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Sun Jan 22, 2017 8:48 am    Post subject: Reply with quote

"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
View user's profile Send private message
Weedoze
Smarty n00b


Joined: 18 Jan 2017
Posts: 4

PostPosted: Wed Mar 08, 2017 7:58 am    Post subject: Reply with quote

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
Code:
{$body}
inside to display the page needed.

My problem is that all the page will be now escaped because of
Code:
{$body}
.

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
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Wed Mar 08, 2017 4:45 pm    Post subject: Reply with quote

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
View user's profile Send private message
Weedoze
Smarty n00b


Joined: 18 Jan 2017
Posts: 4

PostPosted: Mon Mar 13, 2017 7:07 am    Post subject: Reply with quote

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
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Mon Mar 13, 2017 5:52 pm    Post subject: Reply with quote

Read entire documentation.
Or pay me to retype it here for you.
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP