In my last posting, I demonstrated how to create a header and footer file to be included at the top and bottom of all, or at least many, pages. This makes it easy to modify those parts and have the changes automatically spread across all the pages that share that header and footer file. This is one of the things a CMS simplifies for the user.
But what if part of your header, or footer, file is your navigation system and you want the button or link to change when the page associated is chosen? That means your header, or footer, must change depending on what page it's included on. Actually, that's one of the beautiful things about PHP - since it's commands are processed prior to the display of the page, you can program those changes to happen for you automatically.
For several years now, I've been creating mini CMS's without realizing it - actually before there was such a term. It's made all the difference in the world in maintaining websites, especially with over 50 sites like we watch over. How do I do it? Thought you'd never ask. :)
This requires either PHP or SSI (Server Side Includes). I'll be talking about the PHP method here, but can show the other if there's a demand.
First step is to create your first page normally and get it just the way you want it. Then examine your source to see what will be repeated on the rest of the pages on the top and bottom.
Whatever part of the code will be repeated at the top of each page, remove from your page and paste into a document of it's own called header.php. The part that will be at the bottom of each page, remove and place in a document called footer.php. In your original document, put the following in place of the contents of the new header.php: