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


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-11-2008, 11:04 AM
Junior Member
 
Join Date: Dec 2007
Posts: 3
Default [ZF] renders twice the view script....?

Hi,

I'm playing with the ZF. When I render a view, it gets rendered twice....

Here is my controller script:

PHP Code:
<?php

class TestController extends Zend_Controller_Action
{


  function 
testViewAction()
  {
  
    
$view = new Zend_View();
    
$view->assign('a'"Hay");
    
$view->assign('b'"Bee");
    
$view->assign('c'"Sea");
    
    
$view->setScriptPath('application/views/scripts/test/');
    
    
$render $view->render('test-view.phtml');
    
    echo(
$render);
  
  }

}
Here is my view script:
PHP Code:

<ul>
<li><?php echo($this->a); ?></li>
<li><?php echo($this->b); ?></li>
<li><?php echo($this->c); ?></li>
</ul>
Here is the outputed html. As you'll notice, the first rendering doesn't get what is between the php tags...

Code:
<ul>
<li></li>
<li></li>
<li></li>
</ul>
<ul>
<li>Hay</li>
<li>Bee</li>
<li>Sea</li>
</ul>
I've chcked my index/bootstrap, Zend_View isn't instantiated somewhere else...

I'm a bit lost

Regards,

-jj.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 07-11-2008, 11:54 AM
Junior Member
 
Join Date: Oct 2007
Location: Augusta, GA
Posts: 9
Default

Hello,

Unless you told your front controller explicitly not to render the corresponding view for the controller, it does it by default. In other words, your controller should look like:

PHP Code:
class TestController extends Zend_Controller_Action
{


  function 
testViewAction()
  {
  
    
$view = new Zend_View();
    
$view->assign('a'"Hay");
    
$view->assign('b'"Bee");
    
$view->assign('c'"Sea");
  
  }


This SHOULD work unless you have any environmental changes. If it doesn't, please respond with you bootstrap.

Thanks,

Steve
__________________
Steve Siebert
Zend Certified Engineer
General Dynamics IT
www.get-dev.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 07-11-2008, 02:27 PM
Junior Member
 
Join Date: Dec 2007
Posts: 3
Default

Perfect!
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 06:25 AM.