近期在看YIIpublic $template='{view} {update} {delete}';
以上这种写法,如何单独输出{view},{update}呢
同时以下代码片段还会报错foreach(array('view','update','delete') as $id)
{
$button=array(
'label'=>$this->{$id.'ButtonLabel'},
'url'=>$this->{$id.'ButtonUrl'},
'imageUrl'=>$this->{$id.'ButtonImageUrl'},
'options'=>$this->{$id.'ButtonOptions'},
);
if(isset($this->buttons[$id]))
$this->buttons[$id]=array_merge($button,$this->buttons[$id]);
else
$this->buttons[$id]=$button;
}报错提示:Fatal error: Using $this when not in object context in D:\Wamp\Apache\htdocs\1.01\this.php on line 9

解决方案 »

  1.   

    public $template='{view} {update} ';
    不久可以单独输出view和update了么?
      

  2.   

    <?php
        $template='{view} {update} {delete}';
        echo $template;
      
    ?>
    output:
    {view} {update} {delete}
      

  3.   


    view ,update,delete 分别对应yii grid中的查看按钮,更新按钮和删除按钮组件,需要哪个就加哪个。
    比如,只需要view按钮:
    $template='{view}';
      

  4.   

    这个我也知道的,我想知道如何单独输出view,update啊