Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to implement template inheritance of Smarty template in PHP

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly introduces the PHP Smarty template how to achieve template inheritance, the article is very detailed, has a certain reference value, interested friends must read it!

{extends}

In template inheritance, you can use the {extends} tag within the child template to extend the parent template.

1. {extends} must be placed on the first line of the template.

two。 If the child template is to extend the parent template with {extends}, then it can only have the area of {block}.

3. Any other template content will be ignored.

To extend files other than $template_dir, use the syntax of the template resource.

Note

When you extend a variable with a parent template name, such as {extends file=$parent_file}

Make sure that the $parent_file variable is placed in the same $cache_id. Otherwise, Smarty will not be able to distinguish between different $parent_file variables.

Parent.php page

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report