Wiki articles in category Tips

Showing 101-120 of 158 items.

Using counters with ActiveRecord

Created 7 years ago by davi_alexandre, updated 4 years ago by marcovtwout.

Let's say, for example, that you are developing a blog or some kind of CMS and you want to track the number of times each post was viewed (maybe to show a list of the most viewed ones).

11 1
17 followers
Viewed: 35 767 times
Version: 1.1
Category: Tips

1:n relations sometimes require CDbCriteria.together

Created 7 years ago by fsb, updated 5 years ago by fsb.

There are situations in which Active Record will generate nonsense queries from what a nieve Yii user might think is reasonable code. One such situation is a CActiveDataProvider using CDbCriteria to get data from parent and 1:n child table with a condition on the child table.

15 0
12 followers
Viewed: 45 397 times
Version: 1.1
Category: Tips

CGridView: Render customized/complex datacolumns

Created 7 years ago by Joblo, updated 6 years ago by Joblo.

If you have to display a overview of related data in a table, you can use the CListView, create your view with table/tr/td tags and implement db-queries in the view to display detaildata of the current (master-)record.

53 0
75 followers
Viewed: 160 884 times
Version: 1.1
Category: Tips
Tags: CGridView

Yii Security-extended guide

Created 7 years ago by bingjie2680, updated 7 years ago by bingjie2680.

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 you...

6 6
12 followers
Viewed: 24 384 times
Version: 1.1
Category: Tips

Understanding series articles

Created 7 years ago by GOsha, updated 7 years ago by GOsha.

Here are all wiki articles from "Understanding" series by Yii wiki contributors:

16 0
13 followers
Viewed: 11 115 times
Version: 1.1
Category: Tips

CGridView: Update/create records in a CJuiDialog

Created 7 years ago by Joblo, updated 7 years ago by Joblo.

My article Display the full record in a CJuiDialog uses ajax to view a record in dialog on clicking the 'view-icon'.

12 0
26 followers
Viewed: 52 993 times
Version: 1.1
Category: Tips
14 0
20 followers
Viewed: 47 859 times
Version: 1.1
Category: Tips

Using events with CAction classes

Created 8 years ago by Antonio Ramirez, updated 7 years ago by 张 迪.

As you know, events are used by:

9 0
9 followers
Viewed: 19 040 times
Version: 1.1
Category: Tips

Como trasponer una lista creada con CHtml::checkBoxList

Created 8 years ago by rdjteam, updated 8 years ago by rdjteam.

En ciertas ocasiones tenemos que lidiar con el tema de colocar una lista de checkboxes para hacer una seleccion especifica como es el caso de los dias de la semana para un calendario, para esta labor tenemos el comando CHtml::checkBoxList(), revisando un poco el funcionamiento de este temos los siguientes parametros:

2 0
4 followers
Viewed: 15 176 times
Version: 1.1
Category: Tips

Special $variables in CGridView and CListView

Created 8 years ago by Steve Friedl, updated 8 years ago by Steve Friedl.

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.

22 1
33 followers
Viewed: 71 160 times
Version: 1.1
Category: Tips

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

Created 8 years ago by RusAlex, updated 8 years ago by RusAlex.

I'm developing a web project for a company using Yii framework. We are using a git vcs in our development process. We like to use Yii extensions. But only if they are good.

4 0
8 followers
Viewed: 10 154 times
Version: 1.1
Category: Tips

Shrink Yii, help your IDE and speed up copying

Created 8 years ago by dckurushin, updated 8 years ago by dckurushin.

yii-1.1.8.r3324 framework directory is 10.4 mb size.

9 8
17 followers
Viewed: 11 828 times
Version: 1.1
Category: Tips

Send asset folder path to a javascript of a widget

Created 8 years ago by sensorario, updated 8 years ago by sensorario.

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:

Yii::app()->getClientScript()->registerCssFile($filename);
4 0
9 followers
Viewed: 28 145 times
Version: 1.1
Category: Tips
9 0
15 followers
Viewed: 27 150 times
Version: 1.1
Category: Tips

Using cache in CActiveDataProvider

Created 8 years ago by Stamm, updated 8 years ago by Stamm.

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.

17 0
11 followers
Viewed: 24 637 times
Version: 1.1
Category: Tips

Customizing Yii's formatting rules (extending CFormatter)

Created 8 years ago by Haensel, updated 8 years ago by Haensel.

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)...

12 0
6 followers
Viewed: 19 676 times
Version: 1.1
Category: Tips

Display a nice exception message on ajax requests

Created 8 years ago by Maurizio Domba Cerin, updated 8 years ago by Maurizio Domba Cerin.

in Yii versions previous to 1.1.9 exceptions was handled differently during ajax request and displayed by CApplication::displayException(). This way the exception message displayed on ajax requests could not be customized.
The message for the CGridView delete request with YII_DEBUG set to true l...

12 0
19 followers
Viewed: 43 480 times
Version: 1.1
Category: Tips

Guidelines for good schema design

Created 8 years ago by Steve Friedl, updated a year ago by softark.

Virtually all Yii applications are built on top of a database, and though Yii is very flexible in how it addresses your DB, some design choices make things more convenient than others.

122 0
70 followers
Viewed: 99 716 times
Version: 1.1
Category: Tips

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

Created 8 years ago by 1065227709, updated 8 years ago by 1065227709.

in model add the following code:

3 0
3 followers
Viewed: 9 289 times
Version: 1.1
Category: Tips
Tags: rules

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

Created 8 years ago by Darwin Wen, updated 8 years ago by Darwin Wen.

上一篇 关于 Yii CHttpSession性能优化篇之源码流程分析 有详细分析CHttpSession执行流程,在了解CHttpSession的详细执行流程之后,我们就可以非常轻松的扩展Yii Session,来优化和符合自己的业务流程。

1 1
1 follower
Viewed: 11 877 times
Version: 1.1
Category: Tips