Posts Tagged with zii

Displaying 1-7 of 7 results.
Resolved: Yii CActiveDataProvider CListView pagination error
posted by admin on April 15, 2016
In Controller:

$dataProviderComments = new CActiveDataProvider('Comments',
array(
'criteria' => array(
'order' => 'id DESC',
),
'pagination' => array(
'pageSize' => 10,
'pageVar'=> 'page'
),
)
);

$this->render('/media/view', array('comments'=>$dataProviderComments));

In View:

<?php $this->widget('zii.widgets.CListView', array(
'dataProvider'=>$comments,
'itemView'=>'../comments/_comment',
'ajaxUpdate'=>false,
'template'=>'{sorter}{pager}{summary}{items}{pager}',
)); ?>


When my comments less than 10, all is right, but when will be pagination, start from 11, I see this error

Fatal error: Call to a member function getId() on null in C:\xampp\htdocs\avaim.ru\framework\web\CController.php on line 962
Read more
Resolved: Yii 1.1 CGridView Error 500 Trying to get property of non-object
posted by admin on April 8, 2016
I have CGridView with relation

admin.php in Media view

<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'media-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
'id',
'caption',
array(
'name' => 'gallery_id',
'value' => '$data->gallery->name',
'filter' => CHtml::listData(Gallery::model()->findAll(), 'id', 'name'),
),
),
array(
'class'=>'CButtonColumn',
),
),
)); ?>


Gallery.php Model

class Gallery extends CActiveRecord
{
. . .
public function relations()
{
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(
. . .
'gallery' => array(self::HAS_MANY, 'Media', 'gallery_id'),
);
}
. . .
}


Media.php Model

class Media extends CActiveRecord
{

public function relations()
{
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(
. . .
'gallery' => array(self::BELONGS_TO, 'Gallery', 'gallery_id'),
);
}
}


I see this error

Error 500
Trying to get property of non-object


Error in line

'value' => '$data->gallery->name',
Read more
Resolved: Yii CListView unique id attribute div
posted by admin on March 30, 2016

<?php
$this->widget('zii.widgets.CListView', array(
'dataProvider'=>$dataProvider,
'itemView'=>'_view',
)); ?>


I want to edit and change id of parent divRead more
Resolved: Yii CListView itemView from another directory
posted by admin on March 30, 2016
In controller

$dataProvider = new CActiveDataProvider('Media');
$this->render('index',array(
'dataProvider'=>$dataProvider,
));


In View index.php

<?php $this->widget('zii.widgets.CListView', array(
'dataProvider'=>$dataProvider,
'itemView'=>'_view',
)); ?>


I want to pass $dataProvider to another file in another directory.
For example I want to call the file post/_view.phpRead more
Resolved: Yii 1.1 CDetailView visibility, check condition if else
posted by admin on March 6, 2016
I have CDetailView, and I want to check some condition and if condition is true, allow row output, else hide row from detailview table

<?php
$this->widget('zii.widgets.CDetailView', array(
'data' => $model,
'attributes' => array(
'id',
'username',
'balance',
'pro',
'email_delivery:boolean',
array(
'label' => Yii::t('translation', 'About'),
'type' => 'raw',
'value' => $model->about,
),
),
));
?>


How to write condition to about?Read more
Resolved: Yii 1.1 How to change home name breadcrumbs to another or multilanguage
posted by admin on March 5, 2016
In main layout i have this code

<?php if(isset($this->breadcrumbs)):?>
<?php $this->widget('zii.widgets.CBreadcrumbs', array(
'links'=>$this->breadcrumbs,
)); ?><!-- breadcrumbs -->
<?php endif ?>


I want to change the word Home and include multilanguage outputRead more
Resolved: How To Set The "pagevar" Parameter For The Grid View Widget?
posted by admin on December 25, 2015
Hi,
I have a gridview widget:

$this->widget('zii.widgets.grid.CGridView', array(
'dataProvider' => $model->search(),
'summaryText' => 'صفحه {page} از مجموع {pages} صفحه',
'enableSorting' => false,
'enablePagination' => true,
'ajaxUpdate' => false,
'columns'=>array(
//....
),
));


In the pagination links it includes the model name as prefix to pageVar parameter. is there anyway to set the pageVar property of widget so it changes the links from "index.php?r=item/list&Items_page=2" to "index.php?r=item/list&page=2" ?Read more