Articles in category "tips", sorted by date (updated)X
Displaying 111-120 of 154 result(s).

Special $variables in CGridView and CListView

Updated 6 years ago by Steve FriedlTips11 comments – viewed 66,357 times – ( +27 / -3 ) – version 1.1
The popular CListView and CGridView widgets each take a data provider and iterate over each data object produced, calling the user's code to render each row one at a time, and most are familiar with the use of the $data variable to represent the current model object or array.

how to use github (un)official extension repo in your Yii project

Updated 6 years ago by RusAlexTips4 comments – viewed 9,347 times – ( +4 / -1 ) – version 1.1
Using a git submodule command in your yii project

Send asset folder path to a javascript of a widget

Updated 6 years ago by sensorarioTips4 comments – viewed 24,595 times – ( +4 / -1 ) – version 1.1
When you develop a widget, you could need one image that is in the assets folder, you can use it simply within a css. You can load a css or javascript script doing this:

Shrink Yii, help your IDE and speed up copying

Updated 6 years ago by dckurushinTips4 comments – viewed 10,983 times – ( +10 / -10 ) – version 1.1
In this little tip, I will help you to cut Yii size for about half

Using cache in CActiveDataProvider

Updated 6 years ago by StammTips7 comments – viewed 22,186 times – ( +21 / -1 ) – version 1.1
First param in CActiveDataProvider could be a string with model name or instance of class. So, you may use CActiveRecord::cache() for cache, but you need set third param to 2, because you should cache 2 queries: counting and get data.

Customizing Yii's formatting rules (extending CFormatter)

Updated 6 years ago by HaenselTips0 comments – viewed 17,823 times – ( +14 / -1 ) – version 1.1
CFormatter is one of Yii's core components and used to format values displayed in widgets like CGridView or CDetailView. All classic formats like numbers, text, urls or datetime are supported but you may have to use a formatting rule that isn't built in. Let's say we want to display arrays of strings (like tags associated with a product model). When using CDetailView we would usually make use of PHPs implode function to create a simple string value of all values in the $product->tags array.

A simple action for CJuiAutoComplete

Updated 6 years ago by Thiago SouzaTips9 comments – viewed 40,523 times – ( +17 / -2 ) – version 1.1
More or less I use auto-complete field for a form. CJuiAutoComplete is a yii widget for this purposes. The common use case is to make an ajax request and retrieve a list from the database. So in this case you have to write a controller action to return you a json encoded list. What if I had a generic action to do this work for me?

Display a nice exception message on ajax requests

Updated 6 years ago by Maurizio Domba CerinTips3 comments – viewed 40,305 times – ( +13 / -1 ) – version 1.1
When an exception is thrown in our code like
tags: error, exception

an easy way to required multi columns(At least one cannot be blank)

Updated 6 years ago by 1065227709Tips0 comments – viewed 7,663 times – ( +2 / -1 ) – version 1.1
in model add the following code:
tags: rules

Yii CDBHttpSession数据库存储session性能优化实战

Updated 6 years ago by Darwin WenTips0 comments – viewed 9,950 times – ( +1 / -2 ) – version 1.1
上一篇 关于 Yii CHttpSession性能优化篇之源码流程分析 有详细分析CHttpSession执行流程,在了解CHttpSession的详细执行流程之后,我们就可以非常轻松的扩展Yii Session,来优化和符合自己的业务流程。