For each column of the CGridView, we can specify name, value, htmlOptions, cssClassExpression etc. In the declarations of the attributes value and cssClassExpression we can use the "special" variable $data, for example like this: 'value'=>'$data->author->username',.
Now we might want to use $data in the declaration of the htmlOptions attribute, which is normally not possible, to generate for example the tag <td id="3" class="name_3">, where 3 is the id of the data model for the current row, i.e. $data->id. That is, we want to be able to use:
Here's a way to accomplish this...
Because Yii intends to be integrated nicely with third-party libraries, it does not define any global functions. Everything in Yii needs to be addressed with full class name or object scopes. For example, to access the current user, we need to use Yii::app()->user; to access application parameters, we need Yii::app()->params['name']; and so on. While editors like textmate can help alleviate the problem of these lengthy typings, it is worthwhile to define global shortcut functions to some commonly used method calls. They will make the application code look cleaner.
Yii's by-default directory organization works well enough, but there are several steps one can take that improve the security and serviceability of the system, especially in the context of multiple Yii projects on the same machine (including multiple versions of the same project).