2015-01-08 13 views
0

나는 다음과 같은보기 도우미를 가지고 완벽하게 잘 작동 :젠드 Framework1, 컨트롤러 당 Zend_View_Helper_ * 기능을 재정의하는 방법이 있습니까?

class Zend_View_Helper_List extends Zend_View_Helper_Abstract 
{ 
    public function list() 
    { 
     return '<ul><li>Something Really Good</li></ul>'; // generated html 
    } 
} 

내 글로벌 레이아웃 myapp.phtml이 있습니다

<div><?php echo $this->list(); ?></div> 

내 질문은 내가 다른 컨트롤러에 list()를 오버라이드 (override) 할 수있는 방법입니다 또는 더 세분화 된, 각 컨트롤러 동작?

각 컨트롤러에 View 변수를 설정하려고했습니다. 예 : $this->view->type을 입력 한 다음 목록 기능 <div><?php echo $this->list($this->type); ?></div>으로 전달하지만 더럽고 올바르게 표시되지 않습니다.

답변

1

특정 컨트롤러의 view/helpers 폴더에 도우미를 넣을 수 있으므로이 컨트롤러에서만 볼 수 있습니다.

조치 당 변경해야 할 경우 도우미 $this->view->setHelperPath('MyScripts/View/Helper/','MyScripts_View_Helper');에 대한 새 경로를 추가 할 수도 있습니다.

0

단일보기 도우미 만 있으면 변수를 효과적으로 사용할 수 있습니다. 당신의 foo는 액션에서

:
이 뭔가를 시도 할 수 있습니다

$this->view->type = 'action_foo'; 

를보기 도우미에서 :

public function list() 
{ 
    if (isset($this->view->type)){ 
     if ('action_foo' == $this->view->type) 
      return '<ul><li>Something Really Good for Foo Action</li></ul>'; // generated html 
     else 
      return '<ul><li>' . $this->view->type . '</li></ul>'; // generated html 
    } 
    else 
     return '<ul><li>Something Really Good</li></ul>'; // generated html 
}