I want to use the public header at the bottom of each page of a website. How can this problem be achieved. I want to use the public header at the bottom of each page of a website. How can this problem be achieved.
Reply content:
I want to use the public header at the bottom of each page of a website. How can this problem be achieved.
For reference only:
Use JS to dynamically request uniform headers and tails, and insert the specified position
Backend solution,#include('header.vm')
Modify templates in batches, but pay attention to compatibility issues.
Server. If nginx is used, enablesub_filter
Module
Subs_filter'''Common header JS code 'I;
We recommend that you use the first method. There are always common JS references!
You can use templates. I know jade as the front-end template. You can define the public part as mixin and include it to each required page. For details, refer to here.
In the php backend, you can also define a variable, save the required html as a string in this variable, and then echo it to each page.
Of course, you need to define a parent class first. All requests first use this parent class to process some public logic, such as adding header/footer, and subclass will process more specific logic.
Reconstruction is required.
It mainly depends on the framework you are using. Most frameworks have templates, which can be used to propose public components for reuse.
header
Content
footer
Page 1.html
Include 'header'; Page 1 content include 'footer ';
Page 2.html
Include 'header'; Page 2 content include 'footer ';
Create a header. php and a footer. php file to write the headers and footer content.
Then, on the page to introduce the header and footer
Other content
PHP implementation:
include 'header.html';...include 'footer.html';
JS implementation:
...《script》 $('#header').load('header.html'); $('#footer').load('footer.html'); 《script》
Yes. After defining the public header file and the final file, you can include it in the main file. As for variables and things, the processing is the same.
Http://document.thinkphp1.cn/manual_3_2.html#template_layout