Hey all, i'm having problems with templates, my site's not showing up at all. Visit www.betterphp.wghq.net to view this. Any ideas, i've done all the debugging methods i know, and there are no errors. Code below (1st template class, then the index.php).
templateClass.php:
<?php
/*
**
* Script Author: Jonathon M.
* Script Title: _templateClass.php
* Script Quick Bio:
* Well this is for creating the
* template system, later on we can
* possibly get a better template ;)
*/
/*
**
* Quick Security Check
* Included on all _Pages...
*/
if( !defined( "IN_SITE" ) ) {
//...hacking attempt
die();
}
/*
**
* class siteTemplate
* Function siteTemplate - Set the template variable
* Function setParameter - Set the {x} stuff to equal this $x (In array)
* Function createPage - Translate, and create the page
*/
class siteTemplate {
var $__Template;
var $__Html;
var $__Parameters = array( );
function siteTemplate( $__Template ) {
$this->$__Template = $__Template;
}
function setParameter ( $__Variable, $__Value ) {
$this->__Parameters[$__Variable] = $__Value;
}
function createPage( ) {
$this->__Html = implode( "",( file( $this->__Template ) ) );
foreach( $this->__Parameters as $key => $value ) {
$template_name = '{' . $key . '}';
$this->html = str_replace( $template_name, $value, $this->__Html );
}
echo$this->html;
}
}
?>
index.php
<?php
/*
**
* Script Author: Jonathon M.
* Script Title: _dbClass.php
* Script Quick Bio:
* This is the introductry
* part of my site, plus some
* updates.
*
*/
/*
**
* Security Precaution
* All non-public files have it
*/
define("INSITE","TRUE");
/*
**
* Include in structure.php
*/
include("_required.php");
include($__reqFolder . "_structure.php");
/*
**
* Let's connect to the Data Base...
*/
$__Link = mysql_connect( $__reqHost, $__reqUser, $__reqPass );
mysql_select_db( $__reqDB, $__Link );
/*
**
* content function - This will
* get my welcome message and news
* from a db
*/
function content( ) {
//First the welcome message.
$welcome = mysql_fetch_array( mysql_query( "SELECT * FROM " . $__reqDBPre . "welcome ORDER BY welcome_id DESC LIMIT 1" ) );
echo'<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse; font-size: 10px; font-family: Verdana; color: #808080; font-weight: bold" bordercolor="#111111" width="100%" id="AutoNumber2">';
echo'<tr>';
echo'<td width="100%"><span style="color: #000080">__Welcome<br>';
echo$welcome['message'];
echo'</span></td>';
echo'</tr></table>';
unset( $welcome );
unset( $db );
//Now the updates...
$row_query = mysql_query( "SELECT * FROM " . $__reqDBPre . "updates ORDER BY update_id DESC LIMIT 5" );
while( $row = mysql_fetch_array( $row_query ) ) {
echo'+Update, Posted on' . $row['date'] . '<br />';
echo$row['update'];
echo'<hr />';
}
mysql_free_result( $row_query );
}
/*
**
* Get template, and let's go
*/
$siteTemplate = new siteTemplate( "/template/_default/index.php" );
$siteTemplate->setParameter( "SITE_TITLE",$__reqSiteName );
$siteTemplate->setParameter( "SITE_CONTENT",content( ) );
$siteTemplate->createPage( );
?>
sorry had the wrong index.php code before ^ ^ ^ tht's real code.