Josh-
30 Nov 2003, 12:42am
The "One Page" Website
-- written by Josh
You may notice, that sometimes you see sites using one or two pages, rather then using TONS of pages. This isn't usually what it seems. Sometimes they may be using a simple script, that makes it seem so. If you don't understand what I'm talking about, look at short-medias forums. They use similar forms of it everywhere. I see one right now, http://short-media.com/forum/newthread.php?s=&action=newthread&forumid=27. Instead of having a page named "s", ect, they have a page named newthread.php that has another type of "section" of it, "s". I use this to manage my websites, pretty much. You can also make custom 404 pages, which can sometimes be useful to you. Instead of having to go to each individual page, such as:
Index.php...
Contact.php..
About.php..
Ect..
(this is just an example.)
You can now only appear to have on file, which may appear as:
Home.php?section=index or Home.php?section=contact.php..
Now to start with the coding of the PHP:
Your index.php file should include the following:
<?php
if ( @!$section ) {
$section = "home";
}
if ( @$result = include ( "$section" . ".php" ) ) {
} else {
include ("404.php");
}
?>
Upon loading of your website, it will say index.php, but will be loading home.php. From linking from page to page, you will only need to use index.php?section=(pagename), no PHP included. You can also include HTML files, ect this way.
However, the most useful part, and mostly main part of this small script, is to have more organization, and the usefulness of custom 404 pages.
Everytime something is entered, other then a file that you have, it will bring up 404.php. You can easily modify it to become 404.html, ect.
For example, lets say you don't have a chat.php file in your folder.
When someone tries to go to index.php?section=chat, rather then loading a regular server or windows 404 error, it will load your 404.php page, ect.
I guess you may not want this code, except for looks, but don't underestimate custom 404 pages. They can be very useful, such as you can include something that will email you when the 404 page is opened. This can be very useful in administrating a website with a large amount of pages.
Hopefully there is someone out here that can make use of this, and I wish them best of luck in doing it.
Your welcome,
Josh.
-- written by Josh
You may notice, that sometimes you see sites using one or two pages, rather then using TONS of pages. This isn't usually what it seems. Sometimes they may be using a simple script, that makes it seem so. If you don't understand what I'm talking about, look at short-medias forums. They use similar forms of it everywhere. I see one right now, http://short-media.com/forum/newthread.php?s=&action=newthread&forumid=27. Instead of having a page named "s", ect, they have a page named newthread.php that has another type of "section" of it, "s". I use this to manage my websites, pretty much. You can also make custom 404 pages, which can sometimes be useful to you. Instead of having to go to each individual page, such as:
Index.php...
Contact.php..
About.php..
Ect..
(this is just an example.)
You can now only appear to have on file, which may appear as:
Home.php?section=index or Home.php?section=contact.php..
Now to start with the coding of the PHP:
Your index.php file should include the following:
<?php
if ( @!$section ) {
$section = "home";
}
if ( @$result = include ( "$section" . ".php" ) ) {
} else {
include ("404.php");
}
?>
Upon loading of your website, it will say index.php, but will be loading home.php. From linking from page to page, you will only need to use index.php?section=(pagename), no PHP included. You can also include HTML files, ect this way.
However, the most useful part, and mostly main part of this small script, is to have more organization, and the usefulness of custom 404 pages.
Everytime something is entered, other then a file that you have, it will bring up 404.php. You can easily modify it to become 404.html, ect.
For example, lets say you don't have a chat.php file in your folder.
When someone tries to go to index.php?section=chat, rather then loading a regular server or windows 404 error, it will load your 404.php page, ect.
I guess you may not want this code, except for looks, but don't underestimate custom 404 pages. They can be very useful, such as you can include something that will email you when the 404 page is opened. This can be very useful in administrating a website with a large amount of pages.
Hopefully there is someone out here that can make use of this, and I wish them best of luck in doing it.
Your welcome,
Josh.