Wiki

Articles in category "tips", sorted by ratingX
Displaying 21-30 of 154 result(s).

Special $variables in CGridView and CListView

Created 5 years ago by Steve FriedlTips11 comments – viewed 64,481 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.

Understanding series articles

Created 5 years ago by GOshaTips0 comments – viewed 9,837 times – ( +16 / -1 ) – version 1.1
Here are all wiki articles from "Understanding" series by Yii wiki contributors:

1:n relations sometimes require CDbCriteria.together

Created 5 years ago by fsbTips5 comments – viewed 39,143 times – ( +16 / -1 ) – version 1.1
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.

Install specific Yii2 vendor extension & dependency without updating other packages.

Created 3 years ago by Kartik VTips0 comments – viewed 16,867 times – ( +40 / -7 ) – version 2.0
The tips here are for advanced usages of composer and its assumed you have read about using composer and have a knowledge of your vendor packages to be updated. Let's consider, you want to update only one specific yii2 vendor library, without updating all the other extension packages?

CGridView: Display the full record (actionView) in a CJuiDialog

Created 5 years ago by JobloTips7 comments – viewed 43,692 times – ( +15 / -1 ) – version 1.1
If you show a model (with a lot of attributes) partially in a CGridView, it can be helpful when the user can take a quick look at the full record with all attributes without displaying the view as a page and afterwards returning back to the gridview.

Styling Radio Buttons

Created 6 years ago by Steve FriedlTips5 comments – viewed 53,258 times – ( +15 / -1 ) – version 1.1
The default behavior with radio button lists is ugly, and I figured out mostly how to style them a coupla different ways. I'll used the blog tutorial example (but with my own posting modes):

CGridView: Update/create records in a CJuiDialog

Created 5 years ago by JobloTips12 comments – viewed 48,792 times – ( +14 / -1 ) – version 1.1
My article Display the full record in a CJuiDialog uses ajax to view a record in dialog on clicking the 'view-icon'.

Real Time Logging

Created 6 years ago by lucifuriousTips3 comments – viewed 26,234 times – ( +14 / -1 ) – version 1.1
I've seen a lot of people asking about the logging facilities in Yii and thought I'd share a nice little class I wrote that provides near real-time logging.

How to ensure unicity to url

Created 6 years ago by zaccariaTips3 comments – viewed 14,178 times – ( +14 / -1 ) – version 1.1
Many time for SEO porpouses is important that each page will have a unique address.
tags: SEO, unique, URL

Customizing Yii's formatting rules (extending CFormatter)

Created 5 years ago by HaenselTips0 comments – viewed 17,203 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.