Welcome to WebmasterWorld Guest from 18.104.22.168
Forum Moderators: phranque
In my limited experience I have found that each time I have wanted to make changes to my website...
..I would have to change all the other webpages in my website to add new links so that the whole website would look uniform.
Quite painful, I'm sure you'll agree.
Can anybody recommend any techniques or website technologies/system/software/books that would enable me to make changes once, so that each page throughout the whole site would be updated automatically?
<?php require "topofpage.inc";?>
Then make a file called topofpage.inc, and put everything you want to be on the top of the page in it. Do the same for navigation, footer, bits of the header, and so on. Anywhere you want.
It will mean some work initially, but once it's in place it makes updating an entire site a doddle.
PHP eh? Sounds like it would make my life a lot easier and time efficient.
How and where can I learn more about this?
Using PHP is very easy. Let's say you want a footer to appear at the bottom of every page. So this might be typed into something like Notepad and saved as 'footer.html'. (Note: I prefer to give my include files proper extensions, not '.inc', as then I know what type they are (HTML or PHP or Text) plus any editor can open them. I also like to put them in a special folder to avoid confusion with other files, but that's just my way of doing this.)
Here's the text you might use for the footer:
<p class="footer">(C) Me 2004! No nicking this page, OK?</p>
Then all you have to do is this. Make sure your web host is running PHP first of course, or it won't work! Any files you want to be processed by PHP simply need the '.php' extension. So just save an existing HTML page and rename it.
Next, another great thing about PHP is that it can go anywhere on the page - even above the first line of your HTML!
To start some PHP code in your page, use the opening tag
and to end it use
. Everything inside those tags is sent to the PHP parser.
Another great thing (there are so many!) is that you can also put in bits of HTML between these tags, only they have to be echoed. So here is what you might do to add the footer to your pages:
<p>Here is the main text on the page. Now comes the footer...</p>
echo '<p>Some more HTML here just for this page only!</p>';
If you just add the footer code on each page, then when you come to change it, all you have to do is edit the file it points to, and all your pages will be updated at once!
I've taken to making my header, footer and menu all includes.
But what you really want for ease of use in the end is a content management system.
One of the main reasons, though, is: php is fun.
A CMS is great, but what if you want something in it that it can't do? With PHP, you can learn enough to code your own. Then you can add what you want!
I would recommend installing a text editor with highlighting for writing code. That way any mistakes (which are easy to make!) stand out, as the colours used for things like variables and strings won't be correct.
Also line numbers are essential, for when PHP comes up with an error, so you know which line it's referring to!
Notepad2 [flos-freeware.ch] is a brilliant example of a free text editor suitable for PHP and HTML coding, but there are many more. Indeed there's even a Webmaster World forum for this too!
The solution to these headaches is a database-driven site design. This is also a great solution to keeping up to date with any new development technologies.
By using a database as your foundation, you can develope your website with the language of your choice - ASP, ColdFusion, JSP, PHP, Perl and ASP.NET/C# etc. And the "content" will remain the same.
If your really inspired...[be afraid..] create your website in all of the currently available languages! :))
Getting your basic site into php and just having the header - footer included would require about two minutes of reading and a few more minutes of actual work (if you go the route of parsing your html files as php), I'd be happy to explain but it's time for me to log out.
I hope you find a solution for your problem that is easy on maintenance and maximizes the fun thing.
PHP is fun for those of us who enjoy programming. Unfortunately it can be too much fun. By that I mean that you find yourself putting too much time into it for what you really want to do. (Dittos for Visual Basic, C, etc.) That's fine if you have the time and are enjoying it, even finer if you are being paid and are enjoying it. But its not so fine if it take time away from what you should be doing.
Another factor is the support from the host for PHP (or other stuff).
If you do learn PHP, enjoy it, have the time, and have a host that supports it, you should learn it and use it.
Mohamed_E points out a good alternative: HTML preprocessing. On this you run a program on your desktop that produces the html pages that are then uploaded to your host. One cheap CMS preprocessor (runs on your computer, no host support needed) is CityDesk (you can use a trial version that is limited to 50 pages to learn and decide if you want it.) It has limitations, but it might do what you want.
Another alternative is to use VBA in Word or other MS Office programs. I have also used mail merge in Word. (Note- always save Word documents as text and then change the .txt extension to .html; never save as html).
Of course, if you like VBA, the same warning above apply. It can be too much fun. (I have found out the hard way - I find most programming addictive).
"Begining PHP4" from Wrox Press ISBN 1-861003-73-0. It's worked well for me to get going. Explains everything step by step, if you have a fair amount of prior programming experience as I do, you will outgrow this book fairly quickly but for non-programmers I recommend it.
(Note that the latest version of PHP is 5.0, so get the newer version of this book if it exists)
Also [php.net...] is where you can get detailed information on each and every function.
PHP is indeed fun!
Change the template and all the pages made from the template will chnage too - you have to ftp the new pages to your site of course.
The idea of a "web page" is always dynamic. Everything is built on the fly with security and personalization taken into account.
For me, if I change a dynamic part of the page, usually the tamplate, it updates the entire site instantly as soon as I publish it.
Nothing new, just another way of doing it.
PHP is fun because it is extremely powerful, but nonetheless has a pretty easy learning curve.
I'm constantly amazed by the simple power of PHP's core functions. Just look at the long list of string functions - almost enough to satisfy any webmaster. The same for dates - you can convert from and to a wide range of formats, or build your own.
I find you start off coding lengthy loops of code then later realise you could have written them much simpler! But that's all part of the fun.