Forum Moderators: mack
I'm a noob when it comes to creating websites. I created my first template and have an organized structure for the site, etc..
However what I realized is that if I want to change the path of one link in the navigation (or something else which I have on every page), I'll have to go to every single page (its html-file) and change the name of the path.
Is there a way around doing this? Using a CMS? I've also heard of 'includes' (I assume this is server side includes = SSI)?
I guess if it costs too much money, I'll have to do it manually for now and make sure my site doesn't get too large for now, because I'm not making any money off my sites and can't afford to spend a few hundred dollars on the right software for this (and have heard most free CMS caused a ton of problems).
Any ideas what I could do so I dont have to edit ? thank you!
<!--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.
Marshall
<!--webbot bot="Include" U-Include="navigation.htm" TAG="BODY" -->
<=== 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.
<!--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" -->
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.
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!). :)
Issue:
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!
Just MHO.
Added:
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]
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...
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!
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
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]
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.
<?php include $_SERVER['DOCUMENT_ROOT'].'/footer.php'; ?>