Printable Version of Topic

Click here to view this topic in its original format

HTMLHelp Forums _ Markup (HTML, XHTML, XML) _ HTML common pill file

Posted by: scott449 Jul 5 2020, 12:10 PM

I have several web sites
They all have a common footer
Is there way to have a common “footer file” then insert some HTML code into all my pages that pills the “footer file” in the footer section of each page.
Huge pain in the ass to update all my footers

this would alos be usefull for other parts of my sites that have common information that is updated regulary

TIA

Posted by: pandy Jul 5 2020, 12:33 PM

Sure, but not with HTML. Unless you use frames. And you don't want to use frames. happy.gif

It's easily done server side. Earlier SSI, Server Side Includes, that's available on Apache was much used and is still perfectly fine to use. It isn't a programming language per se, more a collection of server directives that can be embedded in the HTML.

Nowadays it's more common to use PHP, which is a programming language. The advantage is that if you later want to use other PHP features you can just go ahead. If you start with SSI and want to add PHP later you would have to redo your SSI included and change them to PHP ones.

It all depends on what you want to do and what's available to you on the server. If you are at a free host that maybe don't offer any server side features there are preprocessors that run locally on your machine and basically do what SSI does on the server. The difference is that if you update your included menu or footer you need to run the preprocessor again and upload the changed files to the server.

Posted by: scott449 Jul 5 2020, 12:35 PM

ok thanks for the responce. hoping i could do it in HTML all that other stuff is WAY over my head

thanks for the info

Posted by: pandy Jul 5 2020, 12:48 PM

Actually, it isn't that complicated.

Posted by: Christian J Jul 6 2020, 06:36 PM

QUOTE(scott449 @ Jul 5 2020, 07:10 PM) *

I have several web sites
They all have a common footer

You mean on separate domains, or just different pages on the same domain?

QUOTE
Is there way to have a common “footer file” then insert some HTML code into all my pages that pills the “footer file” in the footer section of each page.

On a single website it's easy, for example here's all the PHP code needed to include the contents of the text file footer.txt:

CODE
<?php include 'footer.txt'; ?>

You may also need to give the HTML files a .php extension instead of .html, though that can be changed.

If you want to include a file from another domain, your server's PHP module must be configured to allow that in https://www.php.net/manual/en/filesystem.configuration.php#ini.allow-url-include this might be up to your webhost support, not sure.

See also https://www.php.net/manual/en/function.include.php

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)