Consultez la FAQ sur le ZF avant de poster une question
Vous n'êtes pas identifié.
Pages: 1
Bonjour à tous;
J'ai commencé avec le fameux exemple tutoriel_zf.
Voici mon index.php
<?php
error_reporting(E_ALL|E_STRICT);
ini_set('display_errors', 1);
date_default_timezone_set('Europe/Paris');
define("CSV_DIR","application/translation/");
// Mise en place des r该rtoires et chargement des classes
set_include_path('.'
. PATH_SEPARATOR . '../library'
. PATH_SEPARATOR . '../library/mylib'
. PATH_SEPARATOR . './application/MyScripts/'
. PATH_SEPARATOR . './application/models/'
. PATH_SEPARATOR . './application/views/'
. PATH_SEPARATOR . get_include_path());
include "Zend/Loader.php";
Zend_Loader::registerAutoload();
// Chargement de la configuration
$config = new Zend_Config_Ini('./application/config.ini', 'general');
$registry = Zend_Registry::getInstance();
$registry->set('config', $config);
// Mise en place de la BDD
$db = Zend_Db::factory($config->db);
Zend_Db_Table::setDefaultAdapter($db);
// Setup controller
$frontController = Zend_Controller_Front::getInstance();
$frontController->throwExceptions(true);
$frontController->setControllerDirectory('./application/controllers');
Zend_Layout::startMvc(array('layoutPath'=>'./application/layouts'));
$frontController->setParam('noErrorHandler', true);
$frontController->throwExceptions(true);
// Run
$frontController->dispatch();
?>Les vues sont placées dans le rep /tutoriel_zf/application/views
sous views il ya scripts et helpers
Je veux rendre un script de vue particulier qui est sous /tutoriel_zf/application/views/scripts/list.phtml
Dans mon IndexController j'ai mis le code suivant :
$this->view->title = "voici un test helper";
Zend_Loader::loadClass('Zend_View');
$v = new Zend_View();
$v->setScriptPath('/tutoriel_zf/application/views/scripts');
$album = new Albums();
$v->my_album = $album->fetchAll();
$v->render('list.phtml');J'ai essayé de changer le rep de vue, j'ai deplacé le script sous un autre rep, toujours le meme soucis
code de list.phtml :
<?php if(isset($this->albums)):
foreach($this->albums as $album) : ?>
<tr>
<td><?php echo $this->escape($album->title);?></td>
<td><?php echo $this->escape($album->artist);?></td>
<td>
<a href="<?php echo $this->url(array('controller'=>'index',
'action'=>'modifier', 'id'=>$album->id));?>">Modifier</a>
<a href="<?php echo $this->url(array('controller'=>'index',
'action'=>'supprimer', 'id'=>$album->id));?>">Spprimer</a>
<a href="javascript:deleteAlbum('<?=$album->id?>', '');">X</a>
</td>
</tr>
<?php endforeach; endif; ?>Malhereusement j'ai toujours l'erreur suivante bien que le script de vue bien existe sous scripts lors de l'appel de $v->render('list.phtml')
ERREUR :
Fatal error: Uncaught exception 'Zend_View_Exception' with message 'script 'list.phtml' not found in path (\tutoriel_zf\application\views\scripts\)' in C:\xampplite\htdocs\library\Zend\View\Abstract.php:917 Stack trace: #0 C:\xampplite\htdocs\library\Zend\View\Abstract.php(816): Zend_View_Abstract->_script('list.phtml') #1 C:\xampplite\htdocs\tutoriel_zf\application\controllers\IndexController.php(157): Zend_View_Abstract->render('list.phtml') #2 C:\xampplite\htdocs\library\Zend\Controller\Action.php(503): IndexController->ziedhelperAction() #3 C:\xampplite\htdocs\library\Zend\Controller\Dispatcher\Standard.php(285): Zend_Controller_Action->dispatch('ziedhelperActio...') #4 C:\xampplite\htdocs\library\Zend\Controller\Front.php(934): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http)) #5 C:\xampplite\htdocs\tutoriel_zf\index.php(58): Zend_Controller_Front->dispatch() #6 {main} thrown in C:\xampplite\htdocs\library\Zend\View\Abstract.php on line 917Merci pour votre aide
Zied
Hors ligne
Pages: 1