向网站添加新页面
很抱歉,如果这个问题看起来有点开放式,但我经常想向我的网站添加新页面。随着我的网站不断发展,这意味着我必须返回并在之前的所有页面上添加指向新页面的链接,这变得越来越耗时。有什么办法解决这个问题吗?自动方法?显然,在理想的情况下,您首先会获得正确的模板页面,但这似乎不允许轻松扩展。大型网站如何应对?谢谢。
sorry if this question seems a bit open ended, but I'm often wanting to add new pages to my website. As my website grows, this means I'm having go back and add a link to the new page on all of my previous pages, which is becoming increasingly time consuming. Is there any way around this? An automatic method? Obviously in an ideal world you'd get the template page correct first, but this doesn't seem to allow for easy expansion. How do the big sites cope? Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的用户服务器端包含。
PHP 中有
include()
和require()
include('filename.php')
会添加 'filename.php' 的内容到包含它的页面。 Require 执行相同的操作,但如果无法找到或使用该文件,脚本就会停止。而不是这样做:
将其放入名为“navbar.html”的文件中,然后执行:
在包含文件中,您可以:
然后在 PHP 文件中:
与执行相同:
...除了您可以更改包含文件,以便它更改每一页。两者的输出都是:
Goodluck!
You user server-side includes.
In PHP there are
include()
andrequire()
include('filename.php')
will add the contents of 'filename.php' to the page it was included on. Require does the same thing, but the script stops if it can't locate or use the file.Instead of doing:
Put it in a file called "navbar.html" and just do:
In your include file you could have:
And then in the PHP file:
It would be the same as doing:
...except that you can change the include file so that it changes every page. The output of either would be:
Goodluck!