2008年12月9日星期二

[fw-mvc] Problem with helper displaying wrong view-file

Hi

 

I have a problem with a helper which might be a bug or I’ve misunderstood something.

 

Here is the helper code…


class P2_View_Helper_PageSidebar extends Zend_View_Helper_Abstract {

private $_sidebar = 'empty.phtml';

private $_parameters;

 

public function pageSidebar()

{

 return $this;

}

 

public function add($path, $parameters=array())

{

 $this->_sidebar = $path;

 $this->_parameters = $parameters;

}

public function __toString()

{

 return $this->view->partial($this->_sidebar, $this->_parameters);

}

 

public function setView(Zend_View_Interface $view)

{

 $this->view = $view;

}

}

 

 

I use this helper to display a sidebar (<?php echo $this->pageSidebar(); ?>) in a template page.phtml. Normally it uses an empty view file called empty.phtml which is located in the application/view/scripts/ folder…and set above to the private variable $_sidebar

 

Yesterday I created a layout file called empty.phtml which is located in the /application/layouts/scripts folder an now it print out that one instead of the previous one???

 

What am I doing wrong or is this an error in the helper? Should not $this->view->partial(‘empty.phtml’, $this->_parameters); print out the file in application/view/scripts/ folder. Why is the empty.phtml in layouts used instead?

 

Regards

/Thomas

 

 

 

 

 

 

 

 

 

 

 

没有评论: