How to introduce public header and footer files in tp5

little bottle
Release: 2023-04-06 10:48:02
forward
4872 people have browsed it

This article mainly describes how tp5 introduces public header and footer files. It has certain reference value. Interested friends can learn about it.

Question: The project needs to introduce public navigation, header, bottom, right part, etc.

First of all, we need to figure out which file the configuration item of thinkphp5 is. As we all know:config.php, as shown in the figure below

You only need to configure the following content in the configuration item

‘template‘               => [
        // 模板引擎类型 支持 php think 支持扩展
        ‘type‘         => ‘Think‘,
        // 模板路径
        ‘view_path‘    => ‘‘,
        // 模板后缀
        ‘view_suffix‘  => ‘html‘,
        // 模板文件名分隔符
        ‘view_depr‘    => DS,
        // 模板引擎普通标签开始标记
        ‘tpl_begin‘    => ‘{{‘,
        // 模板引擎普通标签结束标记
        ‘tpl_end‘      => ‘}}‘,
        // 标签库标签开始标记
        ‘taglib_begin‘ => ‘<‘,
        // 标签库标签结束标记
        ‘taglib_end‘   => ‘>‘,
        ‘taglib_pre_load‘     =>    ‘app\common\taglib\Cc‘, 
    ],
Copy after login

The red part of the above code is the tag library tag that defines the imported public part. The red box in Figure 2 is the imported public part

##Figure 1

Figure 2

where 'taglib_pre_load' => 'app\common\taglib \Cc', this one.

You can use it in the template afterwards

{cc:articles cid="1" field=‘id,title‘ limit="2" order="id asc" id="vo"}
<li><a href="#">{$vo.title}</a></li>
{/cc:articles}
Copy after login
It’s very convenient, I’ll organize it for everyone to see, I hope it will be helpful to everyone

Related tutorials:

PHP video tutorial

The above is the detailed content of How to introduce public header and footer files in tp5. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
tp5
source:cnblogs.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template