In php, smarty implements a multi-template website. In PHP, the smartyreal-time multi-mode website's Dynamic Template model1.htm code: 12345678910111213htmlheadtitle Template 1 titleheadbodyahref? Model1mce_href? Model1 Template 1: how to implement a multi-template website using smarty in php
Template model1.htm code:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
Template 1 Template 1 | Template 2 | Template 3 {$ Title} {$ Content} |
Template model2.htm code:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
Template 2 Template 1 | Template 2 | Template 3 {$ Title} {$ Content} |
Template model3.htm code:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
Template 3 Template 1 | Template 2 | Template 3 {$ Title} {$ Content} |
Php page implementation:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
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 based on parameters { $ Smarty-> display('model1.htm '); } Else { If (file_exists ('Templates/'.'model'.w._getw.'model'}.'.htm ')) // Determine whether the template file exists { $ Smarty-> display('model'.w._getw.'model'{.'.htm '); } Else { Echo "the template parameters are incorrect! "; } } ?> |
Pipeline template model1.htm code: 1 2 3 4 5 6 7 8 9 10 11 12 13 html head title Template 1/title/head body a href =? Model = 1 mce_href =? Model = 1 Template 1 /...