PDA

View Full Version : Simplifying site updates...


CMK2901
07-04-2007, 07:52 AM
When I first started web development, using just plain HTML, I discovered what a time-waster changing the site's background color could become. Then I learned CSS, and that made all that very easy; update a few lines in a single file, and you're good to go.

Then, I considered how I could apply this same sort of process to the entire page and greatly reduce clutter...Javascript seemed the obvious answer. One of my web pages, cmk.byethost22.com, uses this simple structure:


javascript: loadTop();

html: page content

javascript: loadBottom();


This works fine, putting all my site's layout code into a single external file, so updating time consuming things (such as the copyright notice's date) became incredibly easy.

Now, however, with a new site I'm developing, I'm trying to do things the right way: conforming to standards, getting the largest audience possible, etc. Obviously, my javascript method completely destroys the site for people without Javascript; they will see the page content on a white background.

Is there a method for avoiding these time-consuming things without javascript? Can something like PHP/ASP be used and not leave out a lot of the audience (I don't know anything about PHP, but would learn)? The most practical example I can think of is the year on the bottom of the page; updating a copyright notice on 3,000 pages manually is terrible.

fl00d
07-04-2007, 07:56 AM
Yeah you can use a PHP function similar to the Javascript function you were using.

<?php include("file-here.php"); ?>

If the file you wanted to be included isn't in the same directory, you need to specify the paths.
<?php include("/home/your_host_username/public_html/example_folder/file-here.php"); ?>

page.html
<html>
<head>
<title>example</title>
</head>
<body>
<div id="header">Header!</div>
blah blah
<div id="footer"><?php include("footer.inc"); ?></div>
</body>
</html>

Footer.inc:
Copyright&copy2007 ...

I don't think there is a limit to what type of files you can include.

Or, you could also use a PHP array, but I find using arrays is better for short text, like titles.

CMK2901
07-05-2007, 01:54 AM
Alright, thanks. I'll look into this.

mlseim
07-05-2007, 03:01 PM
Make sure you change your page extensions from .html to .php

When you get to downloading games (software) using credit cards,
look into something like CubeCart ... PHP/MySQL based shopping cart.
It's free, you can customize it, and it handles software downloads.