PHP Smarty Implementation of the multi-template site method, Phpsmarty implementation of the template _php tutorial

Source: Internet
Author: User

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 ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.