Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.

How to display form result in template including php vars?

 
Post new topic   Reply to topic    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
jamminjames
Smarty Rookie


Joined: 26 Dec 2018
Posts: 5

PostPosted: Wed Dec 26, 2018 11:40 pm    Post subject: How to display form result in template including php vars? Reply with quote

I would like to use a Smarty template to display php variables, which represent sql database text fields. I'd like it to also show the result of the Smarty assigned tags that are stored in those fields.

What I'm doing is giving the user an html form to fill out, which will serve as an email subject and body template they'll use for customers. It involves giving them the tags to use, such as {name}), and writing the results to the db. Then, I want to display the result for them to inspect, and have the tags rendered (e.g. {name} would show as the example "Name" that I have assigned to the tag).

How do I include the database info in the template? I can assign them php variables, like $subject = $row["subject"], but how do I render that in the template? I know we're not supposed to use {php} tags, but I'm having trouble writing a plugin that will do that. I figure someone must have tackled this already, so maybe I shouldn't be trying to reinvent that wheel.

Thanks for any help!
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1532

PostPosted: Thu Dec 27, 2018 10:41 am    Post subject: Reply with quote

You should assign all data to template before rendering.
See documentation.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    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