duan20145 2015-08-23 00:24
浏览 38
已采纳

Yii - 链接到给定模型ID的静态页面

Each model id has a corresponding static page e.g id = 1 of my table has a static page in my views as 1.php. So when i click the link button (implemented in ClistView) it respective static page should be displayed.
How can i implement this functionality?

<?php
        echo CHtml::link('View Detail', array('$data->id.php'),

          // i want 1.php to be displayed for $data->id =1 and 2.php for $data->id= 2

            array('id'=>'mylink','class'=>'btnPrint btn btn-danger',
                'target'=>'_blank',
            ));
        ?>
  • 写回答

1条回答 默认 最新

  • dongnachuang6635 2015-08-23 01:09
    关注
    <?php
    echo CHtml::link(
        'View Detail',
        $this->createUrl('site/static', array('id' => $data->id)),
        array(
            'id' => 'mylink',
            'class' => 'btnPrint btn btn-danger',
            'target' => '_blank',
        )
    );
    

    And in your controller you can create an action as follows:

    public function actionStatic($id)
    {
        $this->render($id);
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部