ProgramingTip

Zend Framework에서 레이아웃 파일을 전환하는 방법은 무엇입니까?

bestdevel 2020. 12. 5. 10:19
반응형

Zend Framework에서 레이아웃 파일을 전환하는 방법은 무엇입니까?


단순한 한 줄짜리라고 확신 할 수 없습니다.

특정 작업에 다른 레이아웃 파일을 어떻게 사용할 수 있습니까?

업데이트 : 이것은 나를 위해 일했습니다, 감사합니다!

// Within controller
$this->_helper->_layout->setLayout('other-layout') //other-layout.phtml

//Within view script
<?php $this->layout()->setLayout('other-layout'); ?>

컨트롤러 내부에서 :

$this->_helper->layout->setLayout('/path/to/your/layout_script');

( 이 문서

를 통해 )

편집 : 경로는 디렉토리가 무엇이든 관련이 있음을 참조합니다 (기본적으로 application/layouts/scripts/)


다음과 같이 사용할 수도 있습니다.

// Within controller
Zend_Layout::getMvcInstance()->setLayout('layout_name');

//Within view script

<?php $this->layout()->setLayout('layout_name'); ?>

레이아웃은 / layouts / scripts / 폴더에 있어야합니다. 명명되지 않은 경로도 지정해야합니다. .phtml을 필요로하는 레이아웃의 이름 만

참고 URL : https://stackoverflow.com/questions/1615956/how-to-switch-layout-files-in-zend-framework

반응형