thinkphp3.1.3中widget用法

今天搞了tp3.1的widget,继承了widget类,但是老是掉用错误,所以换种写法,直接继承action

TestAction.class.php

1 $this->display();//调用模板
2 
3 Group/Home/Widget/TestWidget.class.php
4 
5 class TestWidget extends Action{
6 public function hello($name=”){
7 echo (“hello,”.$name.”!”);
8 }
9 }

 

在模板文件中,调用该挂件

<?php

A(‘Test’,'Widget’)->hello(‘world’);

?>

 

搞不懂手册上的{:W('Cate/Menu')},没有显示。所以琢磨了以上做法。R方法感觉也有点问题,所以用A代替。

posted @ 2014-11-10 10:11  Lion_coder  阅读(258)  评论(0编辑  收藏  举报