简体   繁体   中英

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. 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',
            ));
        ?>
<?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);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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