Setting the Kohana template name dynamically
kohana, php, templates
Solution
this link may have the answer:
http://stii.co.za/php/overriding-default-template-in-kohana-php/
just run your template constructor as this:
public function __construct()
{
$this->template = 'foobar';
parent::__construct();
}
Problem
I can't seem to set the `$template` variable dynamically of a site built on Kohana. If I extend the Template_Controller class, I can set the template name like this: ``` public $template = 'template_file_name'; ``` But I can't set it dynamically like: ``` public $template = $this->setTemplate(); ``` or ``` switch($var): default: public $template = 'filename'; break; endswitch; ``` Changing the `$template` variable using `$this->template` in the constructor breaks the Template_Controller somehow: Fatal error: Call to a member function render() on a non-object I need to set the template filename based on a variable set in the constructor, or perhaps pulled from an external library. Any ideas how to make this possible?