I want to display a view in another browser window.
I need to pass the $model.
Would I use render in the controller?
Not sure of the syntax.
Thanks
I want to display a view in another browser window.
I need to pass the $model.
Would I use render in the controller?
Not sure of the syntax.
Thanks
Don’t really understand your question as rendering is done through controller/action.
Maybe you need to set the location of that browser window to that of the controller/action you wish to render?
I wnat to have a link in the list that when a user clicks on it I popup a windows for printing the contents that is retrived from the database.
I need to pass the id or $model to the popup so I can display the database fields.
I did this in codeigniter, but they had an easy function called anchor_popup.
Not sure how to do this in yii.
You could use a jQuery dialog. That would be neater IMO.
It will work even if people have a popup-blocker, which I suspect the majority has turned on nowadays.
CJuiDialog is one possible way:
cjuidialog-and-ajaxsubmitbutton/
Thanks, that looks complicated to me.
I need to digest this.
Are there aby simple examples?
There are tons of ways to do it, I do prettyPhoto or lightboxes and play with classes and set the plugins on the onready functions but…
Lets do it veeery simple:
on the view that you display the link that opens the window, htmlOptions:
‘onclick’=>‘javascript: window.open("’.$this->createUrl(‘controller/action’).’");’
develop from there (Jquery dialogs, lightbox, etc)
Hope it helps
Thanks Antonio, I give that a try and work on it.
Where can I find more info on using jQuery to do this?
Regards,
Frank
You can try out fancybox jQuery plugin.
Add this code in your main layout file:
Yii::app()->clientScript->registerCssFile(Yii::app()->baseUrl.'/css/jquery.fancybox-1.3.1.css');
Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl.'/assets/fancybox/jquery.fancybox-1.3.1.pack.js', CClientScript::POS_HEAD);
Yii::app()->clientScript->registerScript('fancyboxClick', '$("a[rel=fancybox]").fancybox();', CClientScript::POS_READY);
Of couse you need to download fancybox archive and extract it into proper location.
Then you just need to change rel property of url to be "fancybox"
<a href="some_link.html" rel="fancybox">here we go</a>
+you need to modify controller action which handle access to "some_link.html" and change layout to false.
enjoy
I am. Thanks a lot.
anyone tried this with CGridView ? (a lot of links)
I have used this proposed solution.
Thanks for this tip and solution
diggy please can you explain in detail … because i tried what you said but i am going wrong somewhere … can you please send a full example … thanks a lot …
you can use this may help full…
‘link’=>array(
'header'=>'Go to...',
'type'=>'raw',
'value'=> 'CHtml::button("button label",array("onclick"=>"document.location.href=\'".Yii::app()->controller->createUrl("Cities/create",array("city_id"=>$data->city_id))."\'"))',
i added in my admin page this button will come in gridview…
<?php $this->widget(‘zii.widgets.grid.CGridView’, array(
'id'=>'cities-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
'city_id',
'city_name',
'Discription',
'city_laitute',
'city_lontute',
'pic',
/*
'more',
*/
'link'=>array(
'header'=>'Go to...',
'type'=>'raw',
'value'=> 'CHtml::button("button label",array("onclick"=>"document.location.href=\'".Yii::app()->controller->createUrl("Cities/create",array("city_id"=>$data->city_id))."\'"))',
// ‘javascript: window.open("’.$this->createUrl(‘controller/action’).’"));’,
// ‘value’=>‘CHtml::button(“button label”,array(“onclick”=>“window.open(”’.$this->createUrl(‘cities/create’).’")));’,
),
array(
'class'=>'CButtonColumn',
),
),
)); ?>