Displaying 51-60 of 109 results.
Resolved: Yii CGridView custom column not and not show html data attribute
posted by admin on April 24, 2016

echo CHtml::link(
CHtml::image(Yii::app()->request->baseUrl.'/images/op-create.png', "image", array("width"=>30)),
Yii::app()->request->baseUrl.'/images/op-create.png',
array("class"=>"highslide", 'rel'=>'myrel'));

output :

<a class="highslide" rel="myrel" href="/web/images/op-create.png"><img width="30" src="/web/images/op-create.png" alt="image" /></a>



$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'loc-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
array('name'=>'loc_picture',
'type'=>'html',
'header'=>'Picture',
'value'=> 'CHtml::link(CHtml::image(Yii::app()->request->baseUrl.$data->loc_picture, "image", array("width"=>30)), Yii::app()->request->baseUrl.$data->loc_picture, array("class"=>"highslide", \'rel\'=>\'myrel\'))',
'htmlOptions'=>array('width'=>'40','style'=>'text-align:center;'),
),
),
));

output :

<a class="highslide" href="/web/pictures/noimage.jpg"><img width="30" src="/web/pictures/noimage.jpg" alt="image" />

Why output in CGridView, REL="myrel" not shown???Read more
Resolved: Yii CGridView get selected row event on shoose
posted by admin on April 23, 2016
as someone in another topic said, "I did my best to search for answers but didn't find the a solution".

First, I am newbie in Yii.

I have 2 frames, the 1st has a CGridView component that print data from MySql tables. My goal is when I click on a row in CGridView, let I know in the 2nd frame which rows where selected.

I have the CGridView with multiple selection, the frames, and read that selectionChanged is a "a javascript function that will be invoked after the row selection is changed. The function signature is function(id) where 'id' refers to the ID of the grid view. In this function, you may use $.fn.yiiGridView.getSelection(id) to get the key values of the currently selected rows."

My problem is, I don't know how to use selectionChanged function.Read more
Resolved: Yii CGridView change pagination page parameter
posted by admin on April 23, 2016
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 "[del]index.php?r=item/list&Items_page=2[/del]" to "index.php?r=item/list&page=2" ?Read more
Resolved: Yii Cmenu add class to item
posted by admin on April 23, 2016
I need an output like this html code

<ul class="yw0">
<li><span class="highlighter"></span><a href="#">Sign in</a>
</li>
<li><a href="#">Register</a>
</li>
</ul>


The code would be similar something but what would be the exact code to create an extra <span class="highlighter"></span> after the li tag and before the a tag**

<?php $this->widget('zii.widgets.CMenu',array(
'id'=>'menu',
'items'=>array(
array('label'=>'Signin', 'url'=>array('/site/signin')),
array('label'=>'Register', 'url'=>array('/site/register'))
),
)); ?>
Read more
Resolved: Yii CGridView pagination not working and alert 500 or 404 error
posted by admin on April 23, 2016
I have trouble about cgridview pagination.
I am using admin page(/{module}/admin that) generated by gii.
it has search form and grid with pagination. its work well without urlmanager

but my team have create urlmanager rule long ago.

'urlManager'=>array(
'urlFormat'=>'path',
'showScriptName'=>false,
'rules'=>array(
'<controller:\w+>/<id:\d+>'=>'<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',

'<module:\w+>/<controller:\w+>/<action:\w+>/<id:\d+>'=>'<module>/<controller>/<action>',

),
),


when I use admin page with this urlmanager rule. It has some problem.
- if not using grid sort or pagination. I can filter in grid and form.
- but if using sort or pagination. I can not filtering in grid and form anymore.

page link is wierd and i think because of some attribute(params) are null like this

/{module}/{controller}/admin/BookManageMain%5Bbmm_code%5D//BookManageMain%5Bbmm_tid%5D/2/.../BookManageMain_page/2/ajax/book-manage-main-grid

if I am copy this url to another tab and Its can not filtering in grid and form too.
but if I remove attribute that has null value(BookManageMain%5Bbmm_code%5D//) I can filter grid and form.

/{module}/{controller}/admin/BookManageMain%5Bbmm_tid%5D/2/.../BookManageMain_page/2/ajax/book-manage-main-grid

console log (not sure filter use POST and sort/page use GET)

before click pagerlink or sorting
.../{controller}/action?BookManageMain%5Bbmm_code%5D=&BookManageMain%5Bbmm_tid%5D=2&...&BookManageMain_page=1&ajax=book-manage-main-grid

after click

.../{controller}/action/BookManageMain%5Bbmm_code%5D//BookManageMain%5Bbmm_tid%5D/2/.../BookManageMain_page/2/ajax/book-manage-main-grid
Read more
Wiki: Yii on update, detect if a specific AR property has been changed on beforeSave()wiki
posted by admin on April 23, 2016
You need to store the old attributes in a local property in the AR class so that you can compare the current attributes to those old ones at any time.

Step 1. Add a new property to the AR class:

// Stores old attributes on afterFind() so we can compare
// against them before/after save
protected $oldAttributes;


Step 2. Override Yii's afterFind() and store the original attributes immediately after they are retrieved.

public function afterFind(){
$this->oldAttributes = $this->attributes;
return parent::afterFind();
}


Step 3. Compare the old and new attributes in beforeSave/afterSave or anywhere else you like inside the AR class. In the example below we are checking if the property called 'level' is changed.

public function beforeSave()
{
if(isset($this->oldAttributes['level']) && $this->level != $this->oldAttributes['level']){

// The attribute is changed. Do something here...

}

return parent::beforeSave();
}
Read more
Resolved: Yii isNewRecord is false in beforeSave?
posted by admin on April 23, 2016
I made a beforeSave method in my model (extends GXActiveRecord), the if isNewRecord never gets triggered. My beforeSave() gets called, though.

When I print the $this->isNewRecord variable, it's false. When is this variable set to false anyway? I'm very sure it's new

public function beforeSave(){


if(parent::beforeSave())
{
if($this->isNewRecord){
$this->setAttribute('doc_status','new');
print "something";
}else{
$this->setAttribute('doc_status','updated');
}
return true;
} else { return false;

}
Read more
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 sum criteria select condition
posted by admin on April 15, 2016
I try to count my views sum count, by this way

$criteria=new CDbCriteria;
$criteria->select='SUM(visits) as SUMvisits';
$criteria->condition='media_id=:media_id';
$criteria->params=array(':media_id'=>$media_id);
$sBalance = Views::model()->find($criteria)->getAttribute('SUMvisits');
var_dump($sBalance);exit();


Something like this, but it is not workingRead more
Resolved: Yii check if user logged in of guest
posted by admin on April 14, 2016
I want to check my visitor type, guest or logged in user.Read more