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

insert pure php code into 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
caedo
Smarty Rookie


Joined: 27 Jun 2008
Posts: 10

PostPosted: Wed Jul 02, 2008 5:11 pm    Post subject: insert pure php code into smarty template Reply with quote

Good day,

I was wandering if there's a way to insert pure php code into a template instead of using the usual {php}{/php} tags ?

I really need to use <?php ?> because I'm injecting the php code through a smarty variable.
so {$var} would have inside <?php echo "hello world"; ?>, for example .


Thanks in advance

Caedo.
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Wed Jul 02, 2008 5:41 pm    Post subject: Reply with quote

It's not possible to inject PHP code in that way.

But why do you need it at all?
Back to top
View user's profile Send private message
caedo
Smarty Rookie


Joined: 27 Jun 2008
Posts: 10

PostPosted: Wed Jul 02, 2008 5:55 pm    Post subject: Reply with quote

Mmmm.... I'm seeking a way to inject php code into the template, this is because I'm building the site dynamically.

I need a way to take some php code that I load in the logic and then inject it in the template.
For example:
I have a helloworld.php file, In the bussiness logic I read the content of the helloworld file and then I want to inject that code into the template I display. I'm doing this because the main template is made up of multiple modules that contain php code.

Is this posible using smarty ?
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Wed Jul 02, 2008 6:08 pm    Post subject: Reply with quote

The idea of SMARTY is to separate business logic fom the design. I still can't understand why it will be necessary to execute PHP code from within the template.

If you can not avoid that script code is call from the template you should use plugins or registred functions.
Back to top
View user's profile Send private message
caedo
Smarty Rookie


Joined: 27 Jun 2008
Posts: 10

PostPosted: Wed Jul 02, 2008 6:16 pm    Post subject: Reply with quote

The first approach I made to this project was using custom-made plugins, it worked fine. The problem is that to simplify the process of making modules, my boss recommended/ordered to change the approach.
I think that you are right about the plugin thing and if that is the only viable way to do it, well theres no other way.

thanks U.tews

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