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

PHP code in smarty template

 
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
kevinchj
Smarty n00b


Joined: 25 Feb 2016
Posts: 1

PostPosted: Thu Feb 25, 2016 9:09 am    Post subject: PHP code in smarty template Reply with quote

Hello i am new here......

How do i include the following code in a .tpl file ?

<?php
require_once "share.class.php";
$share = new share(1);
$share->header()
?>

<?php if ($share->validate()){ ?>
This is the displayed content.
<?php } ?>
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Thu Feb 25, 2016 9:39 am    Post subject: Reply with quote

I though that documentation was absolutely clear on that point?
Embedding barebone PHP code into templates is a ready security breach and should never be done.
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Thu Feb 25, 2016 3:40 pm    Post subject: Reply with quote

It might be better to clearly understand what you need a share class for, and why it creates a header. Whatever the content is that is coming out of header(), that is probably what you want in your template. You could also use smarty to create the content of header by calling $smarty->fetch() in your header() function. But whatever you do, you don't want to try to load your shareclass within Smarty, that should be done in the PHP code.
Back to top
View user's profile Send private message Visit poster's website
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