Kohana 템플릿 이름을 동적으로 설정합니다
문제
나는 설정할 수없는 것 같다 $template
Kohana에 구축 된 사이트의 가변적 인 가변.
Template_Controller 클래스를 확장하면 다음과 같은 템플릿 이름을 설정할 수 있습니다.
public $template = 'template_file_name';
그러나 나는 그것을 동적으로 설정할 수 없습니다.
public $template = $this->setTemplate();
또는
switch($var):
default:
public $template = 'filename';
break;
endswitch;
변경 $template
변수 사용 $this->template
생성자에서 Template_controller를 어떻게 든 나눕니다.
치명적인 오류 : 비 객체에서 멤버 함수 render ()로 호출
생성자의 변수를 기준으로 템플릿 파일 이름을 설정하거나 외부 라이브러리에서 가져 왔습니다.
이것을 가능하게하는 방법이 있습니까?
해결책
이 링크에는 답이있을 수 있습니다.
http://stii.co.za/php/overriding-default-template-in-kohana-php/
템플릿 생성자를 다음과 같이 실행하십시오.
public function __construct()
{
$this->template = 'foobar';
parent::__construct();
}
다른 팁
나는 이것처럼한다 :
public function action_myaction()
{
// template
$this->template = "template/overlay";
parent::before();
// display
$this->template->title = 'My Action';
$this->template->content = View::factory('myaction')
}
제휴하지 않습니다 StackOverflow