Problems with PHP Smarty

Source: Internet
Author: User
The Include function of smarty can be used to introduce a common part,
For example, A.tpl .....

My question came, if A.TPL is not entirely static HTML, there is also a part of the need to assign variables,

So when B.tpl introduced A.TPL,
B.TPL corresponding b.php page is not also to assgin come in A.TPL needed variables .....

Isn't that a lot of trouble? If a page introduces a lot of public modules,,,,

The variables are pulled over.


Reply to discussion (solution)

Is it hard? Daniel!

Include_php is a nice-to-handle componentized templates, and keep PHP code separate from the template files. Lets say you had a template that shows your site navigation, which was pulled dynamically from a database. You can keep your PHP logic this grabs database content in a separate directory, and include it at the top of the template . Now, can include this template anywhere without worrying if the database information is assigned by the application be Fore Hand.
Include_php is a good way to solve template widgets, which allows PHP code to be separated from the template file. For example, suppose you have a template that dynamically extracts data from a database to display site navigation, you can separate the PHP logic part of the data content into a separate folder and include the PHP script at the beginning of the template. Then you can include the template anywhere without worrying about whether the database information has been removed by the program.

The Include function of smarty can be used to introduce a common part,
For example, A.tpl .....

My question came, if A.TPL is not entirely static HTML, there is also a part of the need to assign variables,

So when B.tpl introduced A.TPL,
B.TPL corresponding b.php page is not also to assgin come in A.TPL needed variables .....

Isn't that a lot of trouble? If a page introduces a lot of public modules,,,,

The variables are pulled over.

Using arrays skillfully

Do a plug-in can be, or in a global variable is also OK, this implementation is relatively simple.

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