0

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',
            ));
        ?>
Femme Fatale
  • 870
  • 7
  • 27
  • 56

1 Answers1

1
<?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);
}
JonathanStevens
  • 472
  • 3
  • 9