Question

I'm trying to implement a contact form into a website I'm making. Nobody recommends to just include the php file into a template.

I don't understand how to make or convert an existing contact form to one working with Smarty.

Any guidelines ?

Was it helpful?

Solution

Well, the purpose of smarty is to seperate your code logic from your design template.

So in your contact form, instead of using echo, you should write the output to smarty variables. I.e:

$smarty->assign('email', $email);

At the end of your contact forms PHP you should then load the smarty template

$smarty->display('index.tpl');

I would advice you to read the smarty best practices page as well. It gives detailed information on how smarty templates should be used (and also why not to include plain PHP).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top