Wiki

Articles in category "tips", sorted by date (updated)X
Displaying 91-100 of 134 result(s).

Special $variables in CGridView and CListView

Updated 2 years ago by Steve FriedlTips10 comments – viewed 42,820 times – ( +25 / -1 ) – 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 2 years ago by RusAlexTips4 comments – viewed 6,998 times – ( +4 ) – version 1.1
Using a git submodule command in your yii project

Send asset folder path to a javascript of a widget

Updated 2 years ago by sensorarioTips4 comments – viewed 16,249 times – ( +4 ) – 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 2 years ago by dckurushinTips4 comments – viewed 8,481 times – ( +10 / -9 ) – version 1.1
In this little tip, I will help you to cut Yii size for about half

Using cache in CActiveDataProvider

Updated 3 years ago by StammTips7 comments – viewed 14,578 times – ( +20 ) – 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 3 years ago by HaenselTips0 comments – viewed 12,921 times – ( +14 ) – 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 3 years ago by Thiago SouzaTips9 comments – viewed 28,359 times – ( +16 / -1 ) – 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 3 years ago by Maurizio Domba CerinTips3 comments – viewed 25,939 times – ( +13 ) – 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 3 years ago by 1065227709Tips0 comments – viewed 4,843 times – ( +2 ) – version 1.1
in model add the following code:
tags: rules

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

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