Recently, I started to study the PHP framework Yii, using the self-built zii. widgets, zii. widgets. grid and other components, although very powerful, but the style settings are not flexible enough, {code ...} I will ask you how to use your own html code in yii and write html code in views... recently, I started to study the PHP framework Yii,
Use the self-built zii. widgets, zii. widgets. grid, and other components,
Although powerful, style settings are not flexible enough,
widget('zii.widgets.grid.CGridView', array( 'id'=>'content-grid', 'dataProvider'=>$model->search(), 'filter'=>$model, 'columns'=>array( 'id', 'title', 'times', 'content', 'dc_id', array( 'class'=>'CButtonColumn', ), ),)); ?>
I would like to ask you how to use your own html code in yii,
Write html code in views. Here I will,
In addition, static data can be normally displayed,
But how to bind your html code to the fields in the data model in models,
This won't happen,
For example, how to display data in tables, lists, and pages?
Reply content:
Recently, I started to study the PHP framework Yii,
Use the self-built zii. widgets, zii. widgets. grid, and other components,
Although powerful, style settings are not flexible enough,
widget('zii.widgets.grid.CGridView', array( 'id'=>'content-grid', 'dataProvider'=>$model->search(), 'filter'=>$model, 'columns'=>array( 'id', 'title', 'times', 'content', 'dc_id', array( 'class'=>'CButtonColumn', ), ),)); ?>
I would like to ask you how to use your own html code in yii,
Write html code in views. Here I will,
In addition, static data can be normally displayed,
But how to bind your html code to the fields in the data model in models,
This won't happen,
For example, how to display data in tables, lists, and pages?
// In controllerpublic function actionIndex () {// initialize model $ mymodel = new Mymodel (); // obtain the filter condition $ criteria = $ mymodel-> search (); // if you do not need Criteria, you can directly write the condition Statement (findAll must be the same, but offset and limit must be calculated by yourself), for example, // $ count = Mymodel: model () -> count ("uid =: uid", array ("uid" => intval ($ _ GET ["uid"]); // processing pagination $ count = Mymodel: model ()-> count ($ criteria); $ pages = new CPagination ($ count); $ pages-> pageSize = 20; $ pages-> applyLimit ($ criteria); // get data $ data = Mymodel: model ()-> findAll ($ criteria ); $ this-> render ('index', array ("model" => $ mymodel, // The following part template does not use "pages" => $ pages, "data" => $ data,);} // in template, traverse $ data directly. The element is a Mymodel object instance. Use-> to access attributes.
Id;?> |
Name;?> |
Age;?> |
Gender;?> |
PageCount; $ p ++) {if ($ p = ($ pages-> currentPage + 1) {echo"
- {$ P}
";} Else {echo"
- {$ P}
";}}?>