Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

How to include footer?

Featured Replies

I need to include the footer of my website via a remote source or something as editing every page (a lot of pages) is a time consuming problem. It would be good to have the header as well but there is a different header for every page but only by one class & a couple lines of code such as CSS and such.

 

Thanks in advance!

That's a common request and this is the usual answer:-

 

Form one page complete in the normal way with the footer and check that it validates and displays properly.

 

Open up Notepad or a text editor (not Word) and cut the code that repeats in every page completely (as much or as little as you want, without doctype, html, head or body tags) and paste it into Notepad and save as an "include" file called footer.inc in the same folder as the main pages. You then have only one file to edit if the footer changes.

 

Substitute the code you have cut out with PHP code

<?php include ("footer.inc"); ?>

in the main file and save it with .php filename extension instead of .html or .htm.

 

Do the same with other main pages where the footer repeats and name them with .php extension.

 

You can use .txt, .php, .html or .htm for the "include" file but it distinguishes it as an "include" file in your file list if you use .inc as the filename extension and it's even better if you put all "include" files in a different directory/folder called, say, "includes". You will have to edit the path to suit each page like <?php include ("../includes/footer.inc"); ?> or <?php include ("includes/footer.inc"); ?> if your main pages are in a different folder from the include file, but once set up you won't need to edit it unless you change the folder that the main page is inside.

 

If you use a complete page as an "include" file with .html or .htm for the filename extension the final processed page will have two doctypes, two html tags, two head sections, etc. in an unusual place which is not a good idea so only put the footer code (say the li tags if formed as a list) in the footer.inc file.

 

You can have different "include" files on the same main pages for header and menu and even use "includes" for the parts of the head section that repeat.

 

The PHP code needs to be processed by a server before the result can be seen, either by the hosting service's server just before downloading or by a server like WampServer 2 or XAMPP (which include Apache) on your computer for local viewing, so you won't see the result from the local file on your computer unless you have WampServer 2 or XAMPP installed.

 

Check that your hosting service supports PHP as free webspaces provided by ISPs usually do not.

Edited by Wickham

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.