Ever wonder how others get their content to load in the same place and the menu, header and other regions of the site remain the same. Well, this example will show you how to create your own website engine.
Usage Example
URL: index.php?page=Contacts
SECTION ONE
This section shows the components of loading into the main content area (dynamic region) of your site.
1. The following specifies a default page or path+page.
Your primary (default) page will be called "_Home.php"
<?php
if (!isset($page)) {
$page = "_Home";
}
?>
2. The following is what controls the path and what page to load.
That is specified in the path set in the URL.
<?php
$LoadPage = @include("$page.php");
?>
3. The following will display a message if no page is found or if the path or page name are incorrect.
<?php
if (!$LoadPage) {
echo "Sorry, the requested page is unavailable";
}
?>
SECTION TWO
This section will show you how to load your "static regions" such as your menus, header, navbar and footers.
<?php
$header = @include("_Header.php");
if (!$header) {
echo "Header region could not get displayed";
}
$menu = @include("_Menu.php");
if (!$menu) {
echo "Menu region could not get displayed";
}
$footer = @include("_Footer.php");
if (!$footer) {
echo "Footer region could not get displayed";
}
?>
SECTION THREE
This section will show you how to put it all together using a table and the examples above.
Additional pages you will need to make yourself are:
_Home.php, _Header.php, _Menu.php, _Footer.php
NOTE: DO NOT include html, head or title tags in your added pages.