Templates In Kohana 3.1
Asked Answered
B

2

3

I used them before several months. Then I switched to Fuel. Then I switched back to Kohana.

Problem? I have forgot how to correctly use templates (with that I mean Controller_Template). There was tutorials on Kohana's docs, but now links seem to be broken.

Please remind me how to use them!

Bordereau answered 5/6, 2011 at 19:39 Comment(3)
Some time has passed, but one thing in your post is interesting for me. Why have you switched from Fuel to Kohana?Antidote
Another interesting question is why ever try Fuel?Henchman
Well, I want to try all possible tools... I want to know them! For example, I'm using Python now. :)Bordereau
U
1

If you really want to use them, you have to extend Kohana_Template. Then you would set a public field '$template' to your view name, and then just do $this->template->foo = "foo" to set variables on the template

public class Controller_MyController extends Controller_Template
{
    public $template = "my_view";
    public function action_foo()
    {
        $this->template->foo = "foo"
    }
}

But the core developers discourage people to use it. You could better use some kind of template engine like Kostache to make up your templates.

Unapt answered 5/6, 2011 at 19:45 Comment(2)
just curious, why do they include it, if its usage is discouraged?Anaclitic
Because some people still use it I guess. Not sure though.Unapt
A
-1
$template = 'mytemplate';

function action_index() {
      $template->content = new View("content");
      $template->content->title = "page title"; // depends on the fields in your view
}

this will require that the mytemplate.php and content.php view files exist

Anaclitic answered 5/6, 2011 at 19:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.