|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
caedo Smarty Rookie
Joined: 27 Jun 2008 Posts: 10
|
Posted: Wed Jul 02, 2008 5:11 pm Post subject: insert pure php code into smarty template |
|
|
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 |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Wed Jul 02, 2008 5:41 pm Post subject: |
|
|
It's not possible to inject PHP code in that way.
But why do you need it at all? |
|
Back to top |
|
caedo Smarty Rookie
Joined: 27 Jun 2008 Posts: 10
|
Posted: Wed Jul 02, 2008 5:55 pm Post subject: |
|
|
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 |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Wed Jul 02, 2008 6:08 pm Post subject: |
|
|
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 |
|
caedo Smarty Rookie
Joined: 27 Jun 2008 Posts: 10
|
Posted: Wed Jul 02, 2008 6:16 pm Post subject: |
|
|
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 |
|
|
|
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
|