2011-06-05 71 views
3

我在幾個月前使用過它們。然後我切換到燃料。然後我轉回Kohana。Kohana中的模板3.1

問題?我忘了如何正確使用模板(我的意思是Controller_Template)。 Kohana的文檔有tutorials,但現在鏈接似乎被打破。

請提醒我如何使用它們!

+0

過了一段時間,但您的文章中有一件事對我來說很有趣。你爲什麼從Fuel轉換到Kohana? – 2011-08-02 10:11:29

+0

另一個有趣的問題是爲什麼要嘗試燃料? – SET 2012-07-07 18:33:53

+0

那麼,我想嘗試所有可能的工具...我想知道它們!例如,我現在正在使用Python。 :) – daGrevis 2012-07-09 17:54:37

回答

1

如果你真的想使用它們,你必須擴展Kohana_Template。然後,你將公共領域「$模板」設置爲您的視圖名稱,然後就去做$這個 - >模板 - >富=「foo」的設置在模板上

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

但核心開發人員勸阻變量人們使用它。您最好使用Kostache等模板引擎來組成模板。

+0

只是好奇,爲什麼他們包括它,如果它的使用不鼓勵? – bumperbox 2011-06-05 19:49:10

+0

因爲有人仍在使用它。但不知道。 – Ikke 2011-06-05 19:50:44

+2

爲什麼不鼓勵? – 2011-06-07 15:34:53

-1
$template = 'mytemplate'; 

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

這將要求mytemplate.php和content.php查看文件存在