Ja mam tak:
index.php :
<?php
$objFront = new CCC_Controller_Front;
$objFront->dispatch();
?>
FrontController :
<?php
public function dispatch()
{
$this->objRouter = new CCC_Router($this->objInput, $this->objConfig);
CCC::registrySet('router', $this->objRouter);
$this->objView = new CCC_View;
CCC::registrySet('view', $this->objView);
$controller = strtolower($this->objRouter->getController()); $action = strtolower($this->objRouter->getAction()); $this->perform($controller, $action);
}
public function perform($controller, $action)
{
$objController = new $controller($this);
$objController->$action();
}
?>
Kontroller akcji :
<?php
class CCC_Controller_Action
{
function __construct($objFront)
{
$this->objFront = $objFront;
$this->objView = $this->objFront->getView();
$this->objInput = $this->objFront->getInput();
$this->init();
}
public function init()
{
}
}
?>
<?php
class CCC_View
{
/**
* string $fileName Nazwa pliku PHP który znajduje się w katalogu /app/views
* bez rozszeżenia (.php)
* np. $this->view->display('welcome_message');
*/
final public function display($fileName = null)
{
if(null === $fileName)
throw new Exception ('Klasa CCC_View::display($fileName = null) : $fileName musi być podane');
$filePath = DIR_APP.'views/'.$fileName.'.php';
throw new Exception ('Klasa CCC_View::display($fileName = null) : Nie ma pliku '.$filePath);
include ($filePath);
return $sContents;
}
} // end : class CCC_View
?>
Akcja :
<?php
class IndexController extends CCC_Controller_Action
{
public function init()
{
$this->objView->basePath = $this->objInput->getBasePath();
$this->objView->baseUrl = $this->objInput->getBaseUrl();
$this->objView->router = $this->objFront->getRouter();
}
public function IndexAction()
{
$this->objView->title = 'Welcome';
$site = $this->objView->display('index/index');
}
?>
tpl :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pl" lang="pl">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<link rel="stylesheet" type="text/css" media="screen"
href="
<?php echo $this->basePath ?>/public/styles/skidoo_too.css" />
</head>
<body>
<div id="pageWrapper">
<div id="masthead" class="inside">
<img src="
<?php echo $this->basePath ?>/public/images/CCC_nag_brown.gif" alt="Cash City">
<hr class="hide">
</div>
<div class="hnav">
<ul>
<li><a href="
<?php echo $this->router->createURL(); ?>">Home</a></li
><li><a href="
<?php echo $this->router->createURL('index', 'server'); ?>">Dane servera</a></li
W tpl nie tak jak Ty napisałeś
Tytul: <b>
<?php echo $this -> view
; ?></b>
tylko :
Tytul: <b>
<?php echo $this -> title
; ?></b>
a tablice albo
foreach albo
$array[0]Pozdrawiam