Hey. I'm currently developing a free PHP script, but I realize that people will not want the same template. How can I let the users add custom templates to the script? Are there any good tutorials on this? I've heard to use smarty but I'm not exactly sure how to use it in this respect. Thanks for any answers!
Custom Templates for PHP Script
Collapse
X
-
you create your default templates (with smarty) which are TPL files with {$smarty_assign ed_vars}Hey. I'm currently developing a free PHP script, but I realize that people will not want the same template. How can I let the users add custom templates to the script? Are there any good tutorials on this? I've heard to use smarty but I'm not exactly sure how to use it in this respect. Thanks for any answers!
Please can change the HTML surrounding the variables, remove ones they don't want, etc.
You just have to document what variables your giving them and what type they are (ie. string, array, date, number) even though PHP is loosly typed, it is still a good idea because smarty doesn't always give you obvious clues when you use a variable wrong, such as an array.
example of this implemenation could be:
Then anyone with basic smarty and HTML knowledge can change the template file to suit them.Code://*PHP CODE HERE// $bar = "test"; $smarty->assign("foo",$bar); $smarty->display("tempate_file.tpl");
I hope this is what you were looking for,
Dan
Comment