Wiki

Articles in category "tips", sorted by viewsX
Displaying 41-50 of 133 result(s).

Send asset folder path to a javascript of a widget

Created 2 years ago by sensorarioTips4 comments – viewed 15,421 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:

How to use a component before every action of a controller

Created about a year ago by transistorTips1 comment – viewed 15,079 times – ( +2 / -1 ) – version 1.1
I guess this is a tip on how to execute some code before every action in a controller, because I will tell you how I did it and maybe you can use the idea in your project.

Custom column in TbGridView with icon by condition, find out icon class glyphicons easy (YiiBooster)

Created 8 months ago by KonApazTips4 comments – viewed 14,899 times – ( +2 / -1 )
First of all, You have to find out the class of the desired icon, so visit the http://getbootstrap.com/2.3.2/base-css.html#icons

Adding a date range search for CGridView the easy way

Created about a year ago by mikewalenTips4 comments – viewed 14,733 times – ( +10 ) – version 1.1
After a lot of research, everything I found on adding date range searching to a CGridView advanced search form seemed to involve adding two new public variables (e.g. $date_from, $date_to), 'safe' rules for the new variables, and a rather chunky if/elseif/else check in the search() method. This probably isn't a hassle for most, but because many of the tables in my database contain two or three and sometimes four date columns (e.g. date_created, date_modified, date_deleted etc.), it meant I was having to add up to eight public variables, the corresponding safe rules, and modifying the search() criteria for each date attribute. So, I set about creating a better way and I thought I'd share my work with the community.

Using jQuery UI 1.8.10 themes with Yii 1.1.6

Created 3 years ago by a110yTips7 comments – viewed 14,568 times – ( +2 ) – version 1.1
When using the latest stable jQuery UI themes (1.8.10) with Yii 1.1.6 (which uses 1.8.6) the widgets don't appear (they're invisible but they're there). In order to make them visible you need to change the following line:

Yii Security-extended guide

Created 2 years ago by bingjie2680Tips11 comments – viewed 14,132 times – ( +6 / -6 ) – version 1.1
This article is called extended guide is because there is already a security guide in the Yii tutorial security section. but that guide is not complete in the sense that it does not rise the developers' attention to some other commonly happening attacks: SQL injection and magic URL, which can be major vulnerabilities in your application without much caring.

Using cache in CActiveDataProvider

Created 2 years ago by StammTips7 comments – viewed 13,887 times – ( +19 ) – 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.

Code style

Created 3 years ago by zaccariaTips2 comments – viewed 13,220 times – ( +29 ) – version 1.1
Often, when writing widgets or editing Yii code, it is unclear whether or not the code is following the MVC pattern.
tags: mvc

A simple action for XUpload extension

Created 3 years ago by tydeas_drTips1 comment – viewed 12,548 times – ( +3 ) – version 1.1
All the basic functionality for an action used by the xupload extension. Check resources for the source code of this action
tags: tips, xupload, caction

Customizing Yii's formatting rules (extending CFormatter)

Created 2 years ago by HaenselTips0 comments – viewed 12,500 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.