|Time saving method to updating websites?|
Making global changes to a whole website
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?
You need a server-side language like php, and it's very easy. Just add the following to the top of each page:
<?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.
Or, even better, have *one* web page and have all your content be includes (using PHP/mysql). If you want to do it even better than that, use a database instead of include files.
Thankyou for the response guys!
PHP eh? Sounds like it would make my life a lot easier and time efficient.
How and where can I learn more about this?
Can this be combined with CSS?
would a content management software help?
You might also want to consider SSI if your host supports it.
An alternative that I find very suitable for me is an HTML preprocessor [html-faq.com]. All will allow including files, most will have other nifty features such as conditionals, macro expansion and so forth.
A good but dated discussion of how to include files can be found here: [htmlhelp.com...]
|PHP eh? Sounds like it would make my life a lot easier and time efficient. |
How and where can I learn more about this?
Try the Webmaster World PHP forum! :)
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>
Note: A great thing is that you can also include PHP within your footer file, and also include other files from within it!
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
[b]<?php[/b] and to end it use
[b]?>[/b]. 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>';
And that's it. The echo line is optional - just showing you how to add HTML using it. That way you can create dynamic code - for instance, a different piece of text every time the page is loaded.
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.
Hester's advice here would mean you'd only have to do all your site-wide link changes once, just including the common php header and footer. Later, you might want to go fancy and have all your pages in a certain category output their own common category-based sidebars.
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.
Hehe, you're damn right there! It's also highly addictive.
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!
That is extremely helpful. Thankyou.
Unfortunately I have no programming experience even in HTML I have just used templates and then amended the design in software like dreamweaver.
Is there a book you could recommend to get me started?
I'm looking into the PHP forums right now!
PS why is PHP fun?
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! :))
PHP is fun because it is extremely powerful, but nonetheless has a pretty easy learning curve. This is one of its greatest strengths and weaknesses, since it sometimes encourages people who don't know much about programming to launch ambitious projects, only later to realize that a bit more discipline, which is 'optional' in PHP (you have to willingly follow guidelines) but enforced in other languages, would have saved a lot of time and effort in debugging, long-term code maintenance, and code collaboration.
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.
I am starting to see the fun side of it! Especially as most CMSs seem to be priced around 10,000 USDs!
I've been doing some more web-research on PHP and have decided to take some lessons.
Especially as found something as simple as the include function would pretty much do the job (right?)
You should look for open source CMS, which are almost always free. Most of them are pretty powerful and can compare to some of the commercial offerings.
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).
Try this book:
"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!
Another approach - if you have Dreamweaver (and other web software will also do) - is to use a template for all the pages and just have editable areas for the content.
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.
I use Zope (zope.org) which is a webserver, CMS, application server all built into one.
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.