Refreshing a widget in Yii

Yesterday, I wrote an AJAX shopping basket widget which, as I’m sure you can imagine, I wanted to refresh when items are added or deleted.  However, having written the code to display the widget it confused me for a while … Continue reading

May 17th, 2012

Yii – Example of Creating a submenu widget

This is a continuation of two previous articles, How to make a dynamic Sub-menu and How to make a dynamic sub-menu – UPDATE, which show the mechanisms by which you can build a dynamic submenu system, populating the dropdowns from the relevant controller. … Continue reading

May 1st, 2012

Advanced Logging in Yii

Here are some nice examples of using the logging facilities in Yii  PHP |  copy code |? 0102 ‘log’=>array(03 ‘class’=>’CLogRouter’,04 ‘routes’=>array(05 array(06 ‘class’=>’CWebLogRoute’,07 // you can include more levels separated by commas08 ‘levels’=>’trace, info, error, warning, vardump’,09 // categories are those you used in the … Continue reading

April 24th, 2012

Yii – simple email and mail merge

I needed an email mechanism for a customer that was light and easy to configure. Yii extensions I tried several email extensions from the Yii website all of which I found overly complex to setup and use.  I then remembered … Continue reading

April 5th, 2012

Yii – How to customize a CGridView CbuttonColumn – part 2

Part 2 (see part 1 here)  PHP |  copy code |? 1 array(2 ‘class’=>’CButtonColumn’,3 ‘template’=>’{update}{add}{delete}’, Always set the class to CButtonColumn. The ‘template’ option enables you to name your buttons as you wish. Yii understands the basic crud names of ‘update’, ‘view’ and ‘delete’ but … Continue reading

February 28th, 2012

Adding an additional column as part of CDbCriteria

This was a tough one today and I found the solution in a number of places, but this one was the most helpful. Problem I’ve got an Property Rental application which also holds availability by dates for each property.  If … Continue reading

February 23rd, 2012

Changing the width of a filter column in CGridview

I recently spent an hour or so trying to reduce the width of columns in a CGridView. As I was trying to squash the grid into a narrow space, I wanted some columns to be narrower than others. I tried … Continue reading

February 21st, 2012

Yii – Exit or End a Controller action

To exit or end processing in a controller action use the end  function  PHP |  copy code |? 12 Yii::app()->end();3 4 For example; this may be used to terminate processing if invalid, incorrect or missing parameters are passed  PHP |  copy code |? 12 3 if (empty($_GET))4 Yii::app()->end();5 6

February 13th, 2012

Yii – Uploading and saving images

updated:  5-Apr-2012 A simple example of a method to upload and save images.  In this example, I created a “Photo” model that saves caption & alt text info to be displayed with the images.  If you create a similar model … Continue reading

February 5th, 2012

Date validation in Yii

Moving on from my last post on Yii validation rules for text fields, next I am going to be looking at validating dates and date ranges. The date validator CDateValidator was added to Yii in release 1.1.7 and provides an easy … Continue reading

February 1st, 2012