PHP Template

by Scott Truesdell

This is a version of the template I use on most sites larger than 3 or 4 pages. Generally the only defines that change in this template are TITLE and CONTENT, although there are hooks for specifying different content to fill in the various boxes as defined in the CSS.

All files in the '/content/' directory are clean semantic HTML and are insulated from the containing HTML so that as long as tags are closed, the files in CONTENT can not effect the page layout.

Changing the design for an entire site is simply a matter of pointing to a different style sheet in DOCUMENT_HEAD.

define('WEB', $_SERVER[DOCUMENT_ROOT] . "/");
define('TITLE', "Welcome");
define('LONG_TITLE', TITLE . " - Generic Example Company");
define('CONTENT', WEB . "content/home_page.html");
define('EXTRA_STYLE', NULL);
define('DOCUMENT_HEAD', WEB . "includes/head.html");
define('BANNER', WEB . "includes/banner.html");
define('LEFT_SIDEBAR', WEB . "includes/menu.html");
define('FOOTER', WEB . "includes/footer.html");
define('DOCUMENT_TAIL', WEB . "includes/tail.html");
$body_id = "home";


Error trapping or multiple layouts can be customized as required by variations of the if(file_exists()) calls or other hooks such as if(EXTRA_STYLE).

SEO can be customized with define'(KEYWORDS', "some keywords") and define('DESCRIPTION', "some long-winded description"). SE visibility can be curried by including TITLE in these defines, e.g. define('KEYWORDS', TITLE . "some more words") and similar tricks.