I think it's looking for the file as an absolute path. Try ...
Code:$view->setScriptPath("/var/www/game/application/views/scripts/account");
I've been trying to render a different view than the default, so here's what I've done.
/game/applications/controllers/AccountController.php:
[PHP]
//snip...
$view = new Zend_View();
$view->setScriptPath("/game/application/views/scripts/account");
echo $view->render('test.phtml');[/PHP]
/game/application/views/scripts/account/test.phtml:
[PHP]
<?php
echo("hello world...");
[/PHP]
But when I navigate to AccountController I get:
I've been trying to figure it out for three days straight now, and I still don't know what the problem is. Anyone able to help me out?Code:Fatal error: Uncaught exception 'Zend_View_Exception' with message 'script 'test.phtml' not found in path (/game/application/views/scripts/account/)' in /var/www/game/library/Zend/View/Abstract.php:857
I think it's looking for the file as an absolute path. Try ...
Code:$view->setScriptPath("/var/www/game/application/views/scripts/account");
Hmm, strange, now I get
It seems to be looking for the default script, which I haven't provided. When I do provide it in the default location, it renders that default script - even though a print_r($view->getScriptPaths()) reveals the path asCode:Fatal error: Uncaught exception 'Zend_View_Exception' with message 'script 'test/index.phtml' not found in path (../application/views/scripts/)' in /var/www/game/library/Zend/View/Abstract.php:857
[PHP]Array ( [0] => /var/www/game/application/views/scripts/account/ ) [/PHP]
But that's definitely not where it's looking. :/
Hate to bump, but I still haven't managed to get this working. Anyone got any ideas?
You're creating a new Zend_View object in the action, but there is already a view created automatically. It is rendered at the end of the action function. You can suggest the view script it should run by giving instructions to the viewRenderer helper. eg.
(Zend Framework: Documentation)Code:$this->_helpers->viewRenderer->setScriptAction('test');
This will cause the "test.phtml" file to be rendered, assuming it is in the same directory as the default script.
Brenton Alker
PHP Developer - Brisbane, Australia
blog.tekerson.com | twitter.com/tekerson | brenton.mp
===============
public function updateAction()
{
$view = new Zend_View();
$script_path = APPLICATION_PATH.'/views/scripts/account/';
$view->setScriptPath($script_path);
$view->render('update');
}
I am trying to call update action manually under my account controller as above.
It is not rendering.
If the view script , is not in default standard path i.e view/scripts/<controller>/action.phtml, then how do i render the view?
For ex:
public function newsAction()
{
//If the the phtml is not in the default location
$script_path = APPLICATION_PATH;
$this->view->addScriptPath('/var/www/html/loudbit/application/');
print_r($this->view->getScriptPath());
$this->render('news');
}
The above also not working. How do we make this renders possible? Please help me, trying from 2 days.