[英]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.