Understanding Dynamic Websites

Please allow me to be obtuse for a moment… :rolleyes:

Let’s say that I have a Top Menu with a Dropline Sub-Menu.

Key Point: And this Top Menu/Sub-Menu appears on every single page along with a Right Column on every page that contains advertising.

The Menu looks something like this: (However, it is obviously displayed horizontally across the top of my web pages)

    * News
          o Breaking
          o Local
          o U.S.
          o World
    * Politics
          o and so on...
    * Business
    * Sports
    * Travel
    * Weather
    * Opinion


If the user is on the Home Page and clicks on the “News” tab, then the “News” section should appear below the Menu and to the left of my advertising in the right column.

If I user then drills down in the “News” section by clicking on the “U.S.” Sub-Menu news item, then that content should appear.

Here is what I am being dumb about…

Never having formally built a website, I am used to back in the OLD OLD DAYS when each web page was different. (Think personal website circa 1995!!)

I am confused about how to build a website that has both Static and Dynamic content?!

I mean, you could recreate the Menu code and Right Column (with Advertising) in every single web page, but that seems insane?! :eek:

The website I am building is very “content heavy” and so a lot of it (e.g. articles) will vary but there will also be things that should remain static (e.g. Menus, Log-in areas, Footers, etc).

So how do I intelligently make it so that I don’t have to duplicate code a million times.



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.

Yes, it’s better to use a CMS (Content Management System) for your needs. There are many, but wordpress is easy to use and you can find many themes (designs) and plugins (functionality) already made.

Start with Wordpress, usually is enough and if you really need more power, you can look at other CMS (but 99.99% chances you won’t need it).

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.

So you are saying that most content on my website should come from a database (e.g. MySQL)?? :-/


It will be quite easier to pull/push articles where the content is in a database and you shove the content into a premade template. Essentially a CMS

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?

Won’t hurt and it will add to your skillset. :slight_smile:

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?! :eek:


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. :slight_smile: