繁体   English   中英

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

[英]Yii - linking to static page of a given model id

每个模型id都有一个对应的静态页面,例如,我的表的id = 1在我的视图中有一个静态页面为1.php。 因此,当我单击链接按钮(在ClistView中实现)时,应显示相应的静态页面。
如何实现此功能?

<?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',
            ));
        ?>
<?php
echo CHtml::link(
    'View Detail',
    $this->createUrl('site/static', array('id' => $data->id)),
    array(
        'id' => 'mylink',
        'class' => 'btnPrint btn btn-danger',
        'target' => '_blank',
    )
);

在您的控制器中,您可以创建如下操作:

public function actionStatic($id)
{
    $this->render($id);
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM