|
|
|
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.
Begin engine
| <?php
echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n";
echo "<html>\n";
echo "<meta http-equiv=\"content-type\" content=\"text/html;charset=iso-8859-1\">\n";
echo "<title>Site title goes here</title>\n";
echo "<style type=\"text/css\" media=\"screen\">
<!--
body { color: #000000; font-size: 12px; font-family: Aria }
td { color: #000000; font-size: 12px; font-family: Arial }
a { color: #000000; font-size: 12px; font-family: Aria; text-decoration: underline }
a:hover { color: #8B0000 }
.Header_Region { background-color: #F0E4DD }
.Menu_Region { background-color: #CDDBD8 }
.Primary_Region { background-color: #F5F5F5 }
.Footer_Region { background-color: #CEDBCD }
-->
</style>\n";
echo "<body>\n";
echo "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n";
echo "<tr>\n";
echo "<td class=\"Header_Region\">\n";
// Displays header - _Header.php
$header = @include("_Header.php");
if (!$header) {
echo "Header region could not get displayed";
}
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td>\n";
echo "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" height=\"350\">\n";
echo "<tr>\n";
echo "<td width=\"160\" valign=\"top\" class=\"Menu_Region\">\n";
// Displays menu - _Menu.php
$menu = @include("_Menu.php");
if (!$menu) {
echo "Menu region could not get displayed";
}
echo "</td>\n";
echo "<td valign=\"top\" class=\"Primary_Region\">\n";
// Displays primary content - Default page - _Home.php
if (!isset($page)) {
$page = "_Home";
}
$LoadPage = @include("$page.php");
if (!$LoadPage) {
echo "Sorry, the requested page is unavailable";
}
echo "</td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class=\"Footer_Region\">\n";
// Displays footer - _Footer.php
$footer = @include("_Footer.php");
if (!$footer) {
echo "Footer region could not get displayed";
}
echo "</td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "</body>\n";
echo "</html>\n";
?> | | |
|
| PHP template processing Categories : PHP, Templates, HTML and PHP | | | PHP3: Formmail. Just a cgi formmail, but than in PHP. It is easy to use! Categories : HTML and PHP, Email, PHP, Perl, HTML and PHP | | | a function that builds an HTML select list from any mysql table. Categories : PHP, MySQL, HTML and PHP | | | Message of the Day - Random Message (Needs MySQL!) Categories : Databases, HTML and PHP, PHP, MySQL | | | Alternating background color for HTML table rows Categories : PHP, Databases, MySQL, HTML and PHP | | | Constantly refresh your PHP/HTML page data. Categories : PHP, HTML and PHP, Sybase | | | Expose - PHP template engine, supports server and client-sided caching,a plugin system, multiple languages, template script language is based on PHP itself. Categories : PHP, PHP Classes, Templates, Complete Programs | | | Select with current month Categories : PHP, HTML and PHP, Date Time, Arrays | | | Check parameters validity. Paranoia was designed to check the validity of the parameters that a php page will receive after a form submission. It can be used to check the variables sent by POST or GET Categories : Algorithms, HTML and PHP, PHP, Variables | | | background music script for random notes in a frame Categories : PHP, Content Management, HTML and PHP | | | A very simple way to build and do a hierarchical html categories browser without javascript , just using html php and mySql
Categories : HTML and PHP, Databases, Algorithms, PHP, MySQL | | | PageRank Display Categories : Search Engines, HTML and PHP, PHP | | | PhpView 0.1 - simple php viewer, using temporary files and frames.
Categories : PHP, PHP Options and Info, Debugging, HTML and PHP | | | Automatically printing the contents of an sql table in MySQL. Categories : MySQL, PHP, HTML and PHP, Databases | | | Very minimal templating engine Categories : PHP, PHP Classes, Templates | |
|
|
|