PHP Smarty Implementation of the multi-template site method, Phpsmarty implementation template
In this paper, we describe the method of implementing multi-template website in PHP smarty. Share to everyone for your reference. The implementation method is as follows:
Template model1.htm Code:
Template 1 Template 1 | Template 2 | Template 3 {$title}
{$content}
Template model2.htm Code:
Template 2 Template 1 | Template 2 | Template 3 {$title}
{$content}
Template model3.htm Code:
Template 3 Template 1 | Template 2 | Template 3 {$title}
{$content}
PHP Page Implementation:
<?php require ' libs/smarty.class.php '; Contains the Smarty class library file $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 { $smarty->display (' model1.htm ') according to the parameters; } else { if ( File_exists (' templates/'. Model '. $_get[' model '. HTM ')//Determine if the template file exists { $smarty->display (' model '. $_get[' model '). HTM '); } else { echo ' template parameter is incorrect! "; } } ? >
I hope this article is helpful to everyone's PHP programming.
http://www.bkjia.com/PHPjc/1015430.html www.bkjia.com true http://www.bkjia.com/PHPjc/1015430.html techarticle PHP Smarty Implementation of the multi-template site method, Phpsmarty implementation of the template This article describes the PHP Smarty implementation of the multi-template site method. Share to everyone for your reference. Concrete Implementation Method ...