| 12:03 pm on Jul 30, 2008 (gmt 0)|
You can convert your pages to .php, .asp or .shtml and use includes as you mentioned. You can also use a webbot include:
<!--webbot bot="Include" U-Include="navigation.htm" TAG="BODY" -->
but there are two things. The include page should ONLY contain the navigation because, as you can see, the webbot includes inserts all the information in the <body> tag and, this is a client side include, not a server side.
| 12:45 pm on Jul 30, 2008 (gmt 0)|
|<!--webbot bot="Include" U-Include="navigation.htm" TAG="BODY" --> |
OMG, I can't believe my eyes. That's proprietary Front Page stuff!
<=== Aghast, runs away screaming in terror
You can use PHP includes on pages with an .html or .htm file extension, all you have to do is put an entry in .htaccess for Apache to parse the html files for PHP. I do it on every single site; all you have to do is update one text file and the entire site is updated, wherever you have the include coded.
| 12:56 pm on Jul 30, 2008 (gmt 0)|
It does work. Hey, and empty your SM box. I can't send you mail.
| 1:17 pm on Jul 30, 2008 (gmt 0)|
<!--webbot bot="Include" U-Include="navigation.htm" TAG="BODY" -->
This won't work on any server I run. You have to have Front Page extensions enabled, and Front Page has been discontinued, so it is not a future-proof technology. Fewer and fewer hosts will support this syntax, especially those with non-Windows servers (the majority).
The standard mechanism (built into Apache and other web servers) is via a server-side include:
<!--#include virtual="navigation.htm" -->
| 1:19 pm on Jul 30, 2008 (gmt 0)|
|This won't work on any server I run. You have to have Front Page extensions enabled |
Is that right? As I understood it (and I haven't seen a copy of FP for years) the software actually inserted all the included html prior to upload.
| 1:21 pm on Jul 30, 2008 (gmt 0)|
|the software actually inserted all the included html prior to upload |
In that case, you have to upload via FrontPage and not via a standard FTP/SSH client - and in that case, you still have to have the FrontPage extensions installed on the server... and only use Front Page for authoring (which is even worse!). :)
| 1:25 pm on Jul 30, 2008 (gmt 0)|
Yes Andy, and you have to upload ALL the pages of the site all over again every single time you update the danged FP includes.
I understand that SSI and PHP don't play well together on the same site. If PHP includes are used, rather than SSI, there are all kinds of neat little PHP tricks and time-savers that can be used on the site as time goes on. That's 100% the reason I chose PHP includes and will continue to use them. PHP rocks!
|In that case, you have to upload via FrontPage and not via a standard FTP/SSH client - and in that case, you still have to have the FrontPage extensions installed on the server... and only use Front Page for authoring (which is even worse!). |
Arghhhh! What a horrifying thought. Even M$ stopped releasing and supporting FP.
[edited by: Marcia at 1:28 pm (utc) on July 30, 2008]
| 2:04 pm on Jul 30, 2008 (gmt 0)|
You can parse .html and .htm extensions as SSI. Look in your hosting control panel under apache handlers in cPanel if that is what you are using or turn on SSI in HSphere and then add the extensions or you can use .htaccess to parse them [webmasterworld.com...] .
You then cut out the html code you want as an "include" into a separate page and name it topnav.html for example. You then place in the "exact" area you cut the code out of your page <!--#include virtual="/topnav.html" --> and upload it to the root of your domain (yoursite.com or public_html).
In the future you will only need to update the "topnav.html" file and upload it...
| 2:18 pm on Jul 30, 2008 (gmt 0)|
How to Parse HTML files for PHP [google.com]
Put the entry into .htaccess to do it, and then make a folder for the site called /includes/ so you remember where they all are.
You put elements like navigation into plain text files (like in Notepad) and save them with filenames like topNavigation.php or footer.php
Then, where you want it to appear, you put the following code using the proper filepath to your /includes/ folder:
<?php include('includes/footer.php'); ?>
Basically, you're doing it the same way you code graphics onto pages that are in the /images/ folder. Once you get this working the first time and get a glimpse of the beauty of it, there's no turning back. You will love it!
| 2:51 pm on Jul 30, 2008 (gmt 0)|
thanks for the replies, but I must admit I'm a bit confused now.
It sounds like "includes" isn't any software or something, but simply the process/technique of creating a new file for example navigation.html and then writing a line of code in the .htaccess file so that the host understands that the file navigation.html has to be used for certain .html pages?
Couldn't you simply use a line of code in every html-file for which you need the navigation.html - file ...the same way you do it with CSS? Ok actually this wouldnt be more simple, but why do you reference a CSS.file in each html file, but only reference the include-file in the .htaccess-file, once?
Does it matter whether I use .html files or .php files? If I dont have a dynamical site right now, could I simply go with .html files (for the include-file) and change it later on? I assume later on it would be just as simple as right now?
Sorry, but Im a bit confused! lol guess Ill have to read a tutorial on this stuff
| 3:20 pm on Jul 30, 2008 (gmt 0)|
Nope, the .htaccess method or .httpconf method (through hosting conrol panel) simply tells apache that .htm or .html files can parse SSI (server side includes)instead of the normal .shtml extension associated with SSI.
You do NOT add a line in .htaccess for each include file...
You are correct, no cost or software involved, simply a setting in apache handlers.
Most sites I put together have at least 3-4 includes for things like headers, footers, navigation, and other items that make it very easy to change sitewide in the future by editing one file instead of 100's or 1000's of pages.
[edited by: The_Contractor at 3:22 pm (utc) on July 30, 2008]
| 3:35 pm on Jul 30, 2008 (gmt 0)|
The reason I prefer parsing .htm/.html extensions as SSI instead of PHP is SSI always takes into account the includes start in the root. Meaning using SSI <!--#include virtual="/topnav.html" --> will be called no matter what level your page is at so if it is at "yoursite.com/thisfolder/thatfolder/mypage.html" it will still call the include correctly. Of course you can keep all includes in one folder like <!--#include virtual="/includes/topnav.html" --> and it will still call them correctly no matter where your page is located that is calling the include file.
If you parse .htm/.html as PHP, it would look for the include file <?php include('footer.php'); ?> in the current directory structure the current page calling the include is in (yoursite.com/thisfolder/thatfolder/) ....unless I am completely wrong.
| 3:40 pm on Jul 30, 2008 (gmt 0)|
To reference root you can use the $_SERVER['DOCUMENT_ROOT'] variable:
<?php include $_SERVER['DOCUMENT_ROOT'].'/footer.php'; ?>
| 1:43 pm on Jul 31, 2008 (gmt 0)|
Thanks for the tip !