How to implement a multi-template website using smarty in php _ PHP Tutorial

Source: Internet
Author: User
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 /...

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.