简体   繁体   English

避免重复页眉和页脚

[英]Avoid repeating headers & footers

I am building a website with at least 7 pages and am looking for a way to avoid having to repeat all headers & footers etc. on every single html document.我正在建立一个至少有 7 页的网站,并且正在寻找一种方法来避免在每个 html 文档上重复所有页眉和页脚等。

I know there are frames and iframes but some browsers don't support these and I want to do something more efficient and flexible for updates.我知道有框架和 iframe,但有些浏览器不支持这些,我想做一些更有效和更灵活的更新。 Any ideas/suggestions?有什么想法/建议吗?


Thanks for the information guys.感谢您提供信息。 I'll be sure to try them out.我一定会尝试一下。 One more thing is that I have a login form within my header?还有一件事是我的 header 中有一个登录表单? Will these methods affect it?这些方法会影响它吗?

Regards问候

Yes, server side includes are the way to go, just a few clarifications:是的,服务器端包括 go 的方式,只是一些澄清:

1) You can do it as described by Sotiris if you choose to use PHP - which is very common choice, and btw.virtually all hosts support php. 1)如果您选择使用 PHP - 这是非常常见的选择,您可以按照 Sotiris 的描述进行操作,并且顺便说一句。几乎所有主机都支持 php。

2) Although the file will have extension.php, you can put your pure html code in it. 2) 虽然该文件的扩展名为.php,但您可以将纯 html 代码放入其中。

3) To be able to test and see this on your computer before uploading it, you have to install server on it. 3) 为了能够在上传之前在您的计算机上进行测试和查看,您必须在其上安装服务器。 At this point I think it's simplest and fastest for you to go for some ready made solution - these are downloadable free:在这一点上,我认为 go 对您来说是最简单和最快的一些现成解决方案 - 这些是可免费下载的:

http://www.wampserver.com/en/ (for Windows) http://www.wampserver.com/en/ (适用于 Windows)

http://www.mamp.info/en/index.html (for Mac) http://www.mamp.info/en/index.html (适用于 Mac)

http://tuxtweaks.com/2010/04/installing-lamp-on-ubuntu-10-04-lucid-lynx/ (for Linux) http://tuxtweaks.com/2010/04/installing-lamp-on-ubuntu-10-04-lucid-lynx/ (适用于 Linux)

you can create a php file that will include all required code (for example footer.php ).您可以创建一个包含所有必需代码的 php 文件(例如footer.php )。 Then you can link it adding in every page in the proper place the following code (if you want to add the footer for example):然后你可以链接它在每个页面的适当位置添加以下代码(例如,如果你想添加页脚):

<?php include "footer.php"; ?>

If it is static HTML pages that you are builing, you probably want to think about Server Side Includes如果您正在构建的是 static HTML 页面,您可能要考虑服务器端包含

http://en.wikipedia.org/wiki/Server_Side_Includes http://en.wikipedia.org/wiki/Server_Side_Includes

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM