Yii CGridView hyperlink open in new tab
cgridview, php, yii
Solution
Set the `target` attribute as `_blank` for the link (`<a>`) that will be generated:
<a href="some_url" target="_blank">Foo</a>
With `CHtml::link` :
'value' => 'CHtml::link($data->name, $data->site_url, array("target"=>"_blank"))',
The last parameter to `CHtml::link()` (and most other html helpers in CHtml class), is htmlOptions, which is supposed to be an associative array with html attributes as keys and their values as values:
array(
"target"=>"_blank",
"class"=>"my-css-class",
// ... any other html attribute ..
)
Problem
I have made one column of my yii CGridview as a hyperlink. But on clicking it, it opens link address within the same tab. How can I open the link address in a new tab ? ``` array( 'header'=>'Name', 'name' => 'name', 'value' => 'CHtml::link($data->name, $data->site_url)', 'type' => 'raw', ), ```