Wiki

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

Send asset folder path to a javascript of a widget

Updated 4 years ago by sensorarioTips4 comments – viewed 21,554 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 4 years ago by dckurushinTips4 comments – viewed 9,970 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 4 years ago by StammTips7 comments – viewed 19,448 times – ( +21 ) – 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 4 years ago by HaenselTips0 comments – viewed 15,963 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 4 years ago by Thiago SouzaTips9 comments – viewed 36,339 times – ( +17 / -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 4 years ago by Maurizio Domba CerinTips3 comments – viewed 35,600 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 4 years ago by 1065227709Tips0 comments – viewed 6,311 times – ( +2 ) – version 1.1
in model add the following code:
tags: rules

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

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

adding class and links to Ctreeview node

Updated 4 years ago by bingjie2680Tips2 comments – viewed 14,037 times – ( +4 ) – version 1.1
This article will show you how to add links and class to each node in ctreeview. so you can attach events in js by obtaining handler on anchor or class.
tags: ctreeview, link, class

BaseModuleAR class with MultiActiveRecord

Updated 5 years ago by GustavoTips0 comments – viewed 7,844 times – ( +2 ) – version 1.1
MultiActiveRecord is an extension that add support for multiple database connection for your application.