2013-02-20 115 views
1

我试图用树枝CakePHP的,所以我安装这个插件:
https://github.com/predominant/TwigView嫩枝为CakePHP的

而且在CakePHP的演示中,我们建立了一个博客,我可以在TPL文件中使用此:

{% for post in posts %} 
<tr> 
    <td>{{post.Post.id}}</td> 
    <td>{{post.Post.title}}</td> 
    <td>Edit | Delete</td> 
    <td>{{post.Post.created|date("F j, Y")}}</td> 
</tr> 
{% endfor %} 

我不能去上班,正在将这样的:

<?php 
echo $this->Html->link(
    'Add Post', array('controller' => 'posts', 'action'  => 'add') 
); 
?> 

我已经尝试了所有的这些,和他们没有工作:

{{ html.link("Add Post", {"controller" : "posts", "action" : "add"}) }} 
{{ _view.html.link("Add Post", {"controller" : "posts", "action" : "add"}) }} 
{{ this.html.link("Add Post", {"controller" : "posts", "action" : "add"}) }} 

我没有得到任何错误,它只是被替换为无。任何人都知道我能如何解决这个问题?

回答

0

也许它只是不会将数组作为参数或不明白控制器或动作是什么。请尝试:

{{ html.link("Add Post", "/posts/add" }} 
+0

不,没有差异 – 2013-02-22 19:36:28

0

它逃避输出吗?如果是这样,要获得完整的HTML,使用RAW

{{ html.link("Add Post", {"controller" : "posts", "action" : "add"})|raw }} 
1

你必须明确地声明在控制器中的助手,使其工作:

public $helpers = array('Html', 'Form'); 

见GitHub的问题#14#13在那里我得到这个从。

0

超链接的HTML帮助正确的语法是:

{{ html.link('Add Post', '/posts/add') }}