So how do I intelligently make it so that I don’t have to duplicate code a million times.
To do what you’re planning on doing, it’s relatively complicated unless you have some experience working in PHP or some other scripting language. You can write your HTML files as normal, and save them as .php files instead of .htm
Then, in those files you can enter the following code anywhere inside of your HTML:
<?php include "path/to/file/name.php_or_htm" ?>
So for example, you could have:
<?php include "navigation.php" ?>
The rest of your html code
And if you add that PHP include part in all of your pages, then you can just write the navigation code once (or edit it once), and it will work on all of your pages.
However, it’s not really that simple. To build a site like yours properly, you’ll need to know some pretty advanced PHP.
To save yourself a LOT of time and headache since this seems to be a very large project, might I suggest downloading Wordpress (http://wordpress.org) and using that as your content platform. You can also use Drupal or Joomla.
Your project is essentially exactly why content management systems like Drupal or Joomla or Wordpress exist. They’re fairly easy to install even for non-technical people, and make it easy to set up content indexes, and then details pages for when you click on that content. You can customize their look all you want, and they even have built in user group functionality for if you ever want to hire some writers/editors.
Many corporate and commercial sites are powered by CMS platforms like these.
WordPress will certainly allow you to post your articles and setup the database structure automatically. However people these days are becoming too reliant on WordPress as a be all end all. The problem being it does things for you and you never learn how or why these things are being done. And you have to find a template that is not full of bloated code or has security risks etc. So again it goes back to understanding what is underneath the hood.
The php include as mentioned above is a great way to include your navigation across your site. Edit one file, and it updates over the entire site.
To get started I would follow the advice given here but I would also take the necessary time to learn how to setup and integrate a MySQL database through php on your own for dynamic content.
as rguy84 said yes. However I would advise you to learn how it works. Don’t just rely on the CMS doing everything for you because if it breaks, what steps do you take to fix it if you don’t understand what’s going on?
If every time someone wants to read an article my system has to go out to the database to pull up the article and then populate it in a PHP page, I would think my website would come to a grinding halt in no time?!
Those types of database requests usually take split-seconds; do you see SPF grinding to a halt? The main reason SPF would be slow is due to a extremely high ratio of traffic and lengthy thread pages; not the fact it interrogates a database to retrieve posts and content.
As Rob said the content coming from the database is quick. In fact every major news and forum sites run on databases to supply viewers with content and stories. Unless you get a DoS type hack you won’t have to worry about that. And chances are you won’t encounter that either.