Extended class disables parent function?
Posted: Wed Jan 26, 2011 7:23 pm
Okay so I spend half an hour trying to get to the root of the problem... I finally found it, but do not know how to fix it.
So here is my parent:
and here is my Extended class:
and here is where I execute it all:
So as you can see I execute the setTemplate('default'); first. This should then set the public $templateName to default, but it doesnt and I can not figure out why. I included and echo in the loadTemplate function to make sure it wasn't that and that seemed to work fine. Any ideas?
Cheers,
Dom.
So here is my parent:
Code: Select all
<?php
/**
* Description of template
*
* @author Dominic Sore
*/
class template {
public $templateName;
public function setTemplate($lTemplate){
$this->templateName = $lTemplate;
}
public function loadTemplate(){
echo '<link rel="stylesheet" type="text/css" href="template/'.$this->templateName.'/css/'.$this->templateName.'.css" />';
}
}
?>Code: Select all
<?php
/**
* Description of headerProperties
*
* @author Dominic Sore
*/
class headerProperties extends template {
public $title;
public function setTitle($pTitle){
$this->title = $pTitle;
}
public function insTitle(){
echo '<title>'.$this->title.'</title>';
}
public function insMeta(){
echo '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">';
}
public function createHeader(){
echo '<head>';
$this->insTitle();
$this->insMeta();
parent::loadTemplate();
echo '</head>';
}
}
?>Code: Select all
<?php
/**
* Description of Global_Conf
*
* @author Dominic Sore
*/
class globalConf {
public function __construct() {
/* Require relevant includes */
require_once 'database.php';
require_once 'login.php';
require_once 'template.php';
require_once 'headerProperties.php';
/* Load classes */
$dbConnect = new database();
$logFunc = new login();
$tempProperties = new template();
$headProperties = new headerProperties();
/* Database Functions */
$dbConnect->parseIni();
$dbConnect->dbConnect();
/* Template Properties */
$tempProperties->setTemplate('default');
/* Header Properties */
$headProperties->setTitle('Testing');
$headProperties->createHeader();
}
}
?>Cheers,
Dom.