Ever wondered how anyone else out there with a website as large as Xiao Star always manages to maintain it? My best bet is that everyone hates working with the navigational area. I suppose this question should be running through your head now: "How do these people change the default navigation without losing their mind? Whenever I make a mistake with the links, I have to go through page by page just to change it! What sucks is that my site is 50 pages long, and there doesn't seem to be a good way to help me change the mistake instantly on every page!"
Or how about this: "I want to change the layout, but I hate to have to go through 30+ pages just to change the HTML coding at the spots! Aargh!"
Yeah, everyone wants an easy way out. No matter how hard you claim that you're hardworking, a small thing like correctiong an error in the navigational area can drive one crazy - and deep down, I know you're lazy too ^_~ But don't worry; there's an answer to all your navigational editing woes - PHP.
So what's needed to use this nifty little thing? I'd say, a host that supports PHP. GeoCities and Freewebs are strictly no-nos, they don't support it. But 100WebSpace does ^^
Now having set aside the requirements, let's get to business.
Let's look at a typical example of a HTML page. I'm not so sure how yours looks like, but here's mine:
<!--Begin header images and navigation-->
<html>
<head>
<link href="style.css" type=text/css rel=stylesheet>
<body>
<img src=header.jpg>
<!--Begin Content-->
Hi! This is Ariane Kinoshita. Welcome to Flyaway-Dreams, my personal site where I host lots of
fun stuff and crap. ^^ Enjoy your stay and don't forget to leave a footprint on my tagboard!
<!--End Content-->
<!--Begin Copyright notice-->
Flyaway-Dreams is copyrighted to Ariane Kinoshita. All rights reserved.
</body>
</html>
Notice that I've split up the document into 3 parts? That should make the rest easier to understand. Now we'll take the top part - yes, the first part - and cut it, pasting it into a seperate document in Notepad. Save it as "header.php".
You should now have this left in your original document:
<!--Begin Content-->
Hi! This is Ariane Kinoshita. Welcome to Flyaway-Dreams, my personal site where I host lots of
fun stuff and crap. ^^ Enjoy your stay and don't forget to leave a footprint on my tagboard!
<!--End Content-->
<!--Begin Copyright notice-->
Flyaway-Dreams is copyrighted to Ariane Kinoshita. All rights reserved.
</body>
</html>
See the bottom part? It's the copyright notice, yes. We want that to show up on every page, no? So cut it and paste it into a new blank document, this time saving it as "footer.php".
I bet that you're left with this as what used to be your original document: ^_~
<!--Begin Content-->
Hi! This is Ariane Kinoshita. Welcome to Flyaway-Dreams, my personal site where I host lots of
fun stuff and crap. ^^ Enjoy your stay and don't forget to leave a footprint on my tagboard!
<!--End Content-->
We're going to modify it a little...hang on, it's just a bit more left. Type this at the top part of your document:
<?php include ('header.php'); ?>
All done? Good. Now do the same at the bottom part, but change 'header.php' to 'footer.php'. After that, save your document as 'index.php'. You may change 'index' to whatever other filename if you wish ^^
I'll explain the syntax: the include() function of PHP tells the server to suck in the external file specified, lock, stock and barrel into the file opened. So what our snippet of PHP code here does is telling the server that parses the file to take all the code from the 'header.php' document and place it in our document - in this case, index.php. Then the server will treat the included code as regular HTML, outputting it to the browser. Same goes when the server sees 'footer.php'.
That done, now upload 'header.php', 'footer.php' and 'index.php' to your web host. Type in the URL of index.php, say http://www.yourdomain.com/index.php into your web browser. If all goes well, you should see the page just as it would look like when you coded everything in HTML. If you get an alert window asking if you would like to save the file to your computer...you know that your host doesn't support PHP - look for another one. @_@
But wait! I haven't explained another thing: What if you make a mistake in the links? Say, you misspelled "DNW Top 100" and wrote "DMW Top 100" instead? (Yes, it happens!) Simple. Change the error in 'header.php', coz' that's where your navigation is located at. Now every page that has the "<?php include ('header.php'); ?>" tag will automatically output the changes. ^^
Changing layouts is the same, just edit where necessary.
If you're still confused, think of it as a treasure map torn into 3 pieces and being put together again with a PHP command. ^_^ Remember to name your files with the .php extension! Otherwise, that code of yours ain't gonna work.
It's not hard to use, and it's an awesome tool if you have a large site. Best of luck! ^^
© Ariane Kinoshita @ http://flyaway.kyouki.org.