Wiki

Articles in category "tips", sorted by ratingX
Displaying 31-40 of 146 result(s).

Yii 2 list of path aliases available with default basic and advanced app.

Created 10 months ago by Kartik VTips1 comment – viewed 14,512 times – ( +40 / -5 ) – version 2.0
If you are coming over from Yii 1.x to Yii 2, and already read this guide, you may note that namespaces are very important in Yii 2 to identify classes. But do you know the list of seeded path aliases that come shipped with a basic or advanced app? Here is my attempt to list them.

Adding a date range search for CGridView the easy way

Created 2 years ago by mikewalenTips5 comments – viewed 19,930 times – ( +12 ) – 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.

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

Created 10 months ago by Kartik VTips0 comments – viewed 3,741 times – ( +38 / -5 ) – 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?

Change buttons on our CGridView extending yii

Created 3 years ago by sensorarioTips5 comments – viewed 24,910 times – ( +11 ) – version 1.1
In this tip, I'll help you to change in few second buttons of your CGridView. I hope you like it =).

Using CListView to display items next to each other (in columns)

Created about a year ago by thyseusTips4 comments – viewed 10,170 times – ( +11 )
When using CListView to display multiple views next to each other, we can use the $index variable inside the viewFile to achieve this. As far as i know there is no extension or out-of-the-box functionality for this, so we need to apply a little hack:

Ajax update

Created 4 years ago by zaccariaTips2 comments – viewed 43,367 times – ( +21 / -2 ) – version 1.1
Often happens to have the need of change a part of the page with ajax.
tags: AJAX

Directory independent extensions

Created 4 years ago by GOshaTips3 comments – viewed 9,249 times – ( +16 / -1 ) – version 1.1
Many people want to use downloaded extensions in their own way. As for me most of the extensions require me to correct Yii::import() instructions inside their source code. All these extensions are directory dependent. To avoid the situation described above, I suggest to implement pseudo-anonymous aliases:

A simple action for CJuiAutoComplete

Created 4 years ago by tydeas_drTips9 comments – viewed 31,150 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?

Search method of a model for filters when using dates - unixtimestamp in database

Created 4 years ago by MukkeTips1 comment – viewed 24,143 times – ( +10 ) – version 1.1
I ran into a problem and on irc we worked it out. Since there is a lack on information on filters in genral i thought i'd start sharing all my findings, might be usefull for other people.

Using counters with ActiveRecord

Created 3 years ago by davi_alexandreTips9 comments – viewed 22,029 times – ( +14 / -1 ) – version 1.1
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).