Custom Templates for PHP Script

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • BaKo
    New Member
    • Sep 2007
    • 11

    Custom Templates for PHP Script

    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!
  • dlite922
    Recognized Expert Top Contributor
    • Dec 2007
    • 1586

    #2
    Originally posted by BaKo
    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!
    you create your default templates (with smarty) which are TPL files with {$smarty_assign ed_vars}

    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:

    Code:
    
    //*PHP CODE HERE//
    $bar = "test"; 
    
    $smarty->assign("foo",$bar); 
    $smarty->display("tempate_file.tpl");
    Then anyone with basic smarty and HTML knowledge can change the template file to suit them.


    I hope this is what you were looking for,




    Dan

    Comment

    Working...