Template model1.htm code:
3 4
|
{$title} {$content} |
1 2 3 4 5 6 7 8 9 10 11 12 13 |
{$title} {$content} |
1 2 3 4 5 6 7 8 9 10 11 12 13 |
{$title} {$content} |
php page implementation:
4 11 12 |
<🎜>require 'libs/Smarty.class.php'; //Contains Smarty class library files<🎜> <🎜>$smarty = new Smarty; //Create a new Smarty object<🎜> <🎜>$title = "Test";<🎜> <🎜>$content = "This is a test!";<🎜> <🎜>$smarty->assign("title",$title); //Assign values to variables in the template $smarty->assign("content",$content); //Assign values to variables in the template if(!isset($_GET['model'])) //Select different templates according to parameters { $smarty->display('model1.htm'); } else { if(file_exists('templates/'.'model'.$_GET['model'].'.htm')) //Determine whether the template file exists { $smarty->display('model'.$_GET['model'].'.htm'); } else { echo "The template parameters are incorrect!"; } } ?> |