Wiki

Articles in category "tutorials", sorted by ratingX
Displaying 51-60 of 227 result(s).

CGridView: Use special variable $data in the htmlOptions of a column (i.e. evaluate htmlOptions attribute)

Created 2 years ago by c@cbaTutorials3 comments – viewed 35,526 times – ( +27 / -1 ) – version 1.1
    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: 'htmlOptions'=>array('id'=>'$data->id', 'class'=>'"name_{$data->id}"')     Here's a way to accomplish this...

How to log changes of ActiveRecords?

Created 5 years ago by pfthTutorials7 comments – viewed 31,018 times – ( +34 / -2 ) – version 1.1
A simple and effective way to keep track what your users are doing within your application is to log their activities related to database modifications. You can log whenever a record was inserted, changed or deleted, and also when and by which user this was done. For a CActiveRecord Model you could use a behavior for this purpose. This way you will be able to add log functionality to ActiveRecords very easily.
tags: Logging

How to customize Yii core messages?

Created 5 years ago by qiangTutorials7 comments – viewed 39,916 times – ( +17 ) – version 1.1
Yii core messages refer to static text strings in the core Yii framework code which are meant to be displayed to end-users (e.g. core exception messages, default validation error messages). Customization of these core messages is needed in two circumstances:

How to display static pages in Yii?

Created 5 years ago by qiangTutorials2 comments – viewed 43,769 times – ( +17 ) – version 1.1
In a Web application, we often need to display pages like "about this site", "legal information", whose content are mostly static. There are several approaches to deal with this kind of pages.
tags: static pages

Displaying, sorting and filtering HasMany & ManyMany relations in CGridView

Created about a year ago by yJeroenTutorials8 comments – viewed 38,016 times – ( +17 ) – version 1.1
This tutorial gives you multiple options of how to fully implement showing, sorting and filtering related data in gridviews.

CListView AJAX filtering

Created 3 years ago by DragaTutorials16 comments – viewed 43,829 times – ( +16 ) – version 1.1
This tutorial shows how to filter CListView items by AJAX, and it's compatible with disabled JavaScript users In my case this has been done to filter users list

Dynamic parent and child CGridView on single view. Using $.ajax to update child gridview via controller, after row in parent gridview was clicked.

Created 2 years ago by Gerhard LiebenbergTutorials20 comments – viewed 57,306 times – ( +24 / -1 ) – version 1.1
This wiki is a step-by-step example explaining how the controller, model and the view's CGridView work together. It explains simple things - as well as more complex things that you will anyway quickly have to know. So, even if you don't use dynamic gridviews, take a morning off and thoroughly work through this tutorial. It should save you lots of struggling.

Secure password hash storage and a Yii helper extension

Created 2 years ago by fsbTutorials5 comments – viewed 26,556 times – ( +15 ) – version 1.1
Obsolete

Manage application configuration in different modes

Created 5 years ago by qiangTutorials5 comments – viewed 28,772 times – ( +15 ) – version 1.1
Info: This tutorial references the idea presented in Jonah's excellent blog article.

Manage (Target) Language in Multilingual Applications + A Language Selector Widget (i18n)

Created 2 years ago by c@cbaTutorials10 comments – viewed 25,461 times – ( +15 ) – version 1.1
In case of a multilingual application, one might consider it a reasonable approach to store the preferred language of the user in a session variable, and after that, every time a page is requested, to check this session variable and render the page in the indicated language. This tutorial shows a Yii-way of doing this. We implement an event handler for the onBeginRequest event; as the name of the event suggests, this event handler will be called at the beginning of each request, so its a good place to check whether a language is provided (via post, session or cookie) and set the application language accordingly. We also implement a simple Language-Selector Widget, which can render the language options as ajax-links or as a drop-down list.