简体   繁体   English

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

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

Each model id has a corresponding static page eg id = 1 of my table has a static page in my views as 1.php. 每个模型id都有一个对应的静态页面,例如,我的表的id = 1在我的视图中有一个静态页面为1.php。 So when i click the link button (implemented in ClistView) it respective static page should be displayed. 因此,当我单击链接按钮(在ClistView中实现)时,应显示相应的静态页面。
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',
            ));
        ?>
<?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);
}

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

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