Witam serdecznie.
Mam małe pytanie. Właśnie jestem w trakcie nauki korzystania z ZF. Czytam artykuł z wortal.php.pl dotyczacy korzystania z tego wzorca. Jest tam przykład totyczący strony z płytami CD. Po stworzeniu widoku wyświetla podwójnie treść szablonu. Nie mam pojęcia dlaczego.
Będę bardzo wdzięczny za jakąkolwiek pomoc, z góry dziękuję i pozdrawiam.
Plik index.php
<?php
date_default_timezone_set('Europe/Warsaw');
include "Zend.php";
Zend::loadClass('Zend_Controller_Front');
Zend::loadClass('Zend_Controller_RewriteRouter');
##############################################################
Zend::loadClass('Zend_View');
##############################################################
$view = new Zend_View();
$view->setScriptPath('./application/views');
Zend::register('view', $view); // Tworzymy controller
$router = new Zend_Controller_RewriteRouter();
$baseUrl = substr($_SERVER['PHP_SELF'], 0
,strpos($_SERVER['PHP_SELF'], '/index.php')); $router->setRewriteBase($baseUrl);
$controller = Zend_Controller_Front::getInstance();$controller->setRouter($router);
// Uruchamiamy!
$controller->run('./application/controllers');
$router = new Zend_Controller_RewriteRouter();
$baseUrl = substr($_SERVER['PHP_SELF'], 0
, strpos($_SERVER['PHP_SELF'], '/index.php')); $router->setRewriteBase($baseUrl);
$controller = Zend_Controller_Front::getInstance();
$controller->setRouter($router);
// Uruchomienie!
$controller->run('./application/controllers');
?>
Plik IndexController.php
<?php
class IndexController extends Zend_Controller_Action
{
function indexAction()
{
/////////////////////////////////////////
$view = Zend::registry('view');
$view->title = "My Albums";
/////////////////////////////////////////
echo $view->render('indexIndex.tpl.php'); //echo "<p>in IndexController::indexAction()</p>";
}
}
?>
Plik szablonu indexIndex.tpl.php
<html>
<head>
<title>
<?php echo $this->escape($this->title); ?></title>
</head>
<body>
<h1>
<?php echo $this->escape($this->title); ?></h1>
</body>
</html>