Welcome, Guest. Register Now!
   
Mark Forums Read Mark Forums Read Mark Forums Read


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-15-2008, 02:10 PM
Junior Member
 
Join Date: Jun 2008
Posts: 7
Default Path error when rendering views

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 Code:
//snip...
$view = new Zend_View();
$view->setScriptPath("/game/application/views/scripts/account");
echo 
$view->render('test.phtml'); 
/game/application/views/scripts/account/test.phtml:
PHP Code:
<?php
echo("hello world...");
But when I navigate to AccountController I get:

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'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?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 07-15-2008, 04:23 PM
Junior Member
 
Join Date: May 2008
Posts: 12
Default

I think it's looking for the file as an absolute path. Try ...
Code:
$view->setScriptPath("/var/www/game/application/views/scripts/account");
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 07-15-2008, 08:47 PM
Junior Member
 
Join Date: Jun 2008
Posts: 7
Default

Hmm, strange, now I get
Code:
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
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 as
PHP Code:
Array ( [0] => /var/www/game/application/views/scripts/account/ ) 
But that's definitely not where it's looking. :/
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 07-26-2008, 10:50 AM
Junior Member
 
Join Date: Jun 2008
Posts: 7
Default

Hate to bump, but I still haven't managed to get this working. Anyone got any ideas?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 07-28-2008, 12:20 AM
Member
 
Join Date: Jul 2008
Posts: 46
Default

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.
Code:
$this->_helpers->viewRenderer->setScriptAction('test');
(Zend Framework: Documentation)
This will cause the "test.phtml" file to be rendered, assuming it is in the same directory as the default script.
__________________
Brenton Alker
Brisbane, Australia

http://blog.tekerson.com/
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 08:58 PM.