Can I include a view in Kohana 3 that is not within `application/views`?
I am building a staff area for a website, which is completely different to the main brochure style site.
I have 2 Kohana systems setup. I realise they can both share the same system
and modules
folder.
Now, with the second one, I want to make the main template view a view in a different folder.
I tried this in my base controller
$this->template = DOCROOT . '../~new2/application/views/template.php';
But Kohana is looking for it in its own views
folder as evident by the error I received. I even put a var_dump(file_exists($this->template)); // true
to 开发者_开发百科be sure it was finding the correct file.
Is there a way to add a template file that is not within the views
folder, without hacking the core Kohana code (and if I'm lucky not extending and overloading the view class).
It's quite hacky, but knowing that it is looking in the views
folder, you can point to your view like so.
$this->template = '../../../~new2/application/views/template';
$path = APPPATH . 'views/' . $this->template;
var_dump(realpath($path)); // proper path
var_dump(file_exists($path)); // true
Yeah, it's ugly. But it works.
精彩评论