Yii 1.1: How to add an analogue clock widget on your skeleton application

1 follower


Followings are the simple steps to put an analogue clock widget on your skeleton application that is just generated by yiic.

1. Get the files under the trunk of the code repository using svn.

$ svn checkout http://yii-analogue-clock-widget.googlecode.com/svn/trunk/ <yii-analogue-clock-widget>

2. Create a skeleton application using yiic.

$ cd <yii-demo-directory>
$ ../framework/yiic webapp <app-name>

3. Copy image files and php files to the skeleton application.

$ cp <yii-analogue-clock-widget>/analogue-clock-*.png <app-name>/images/
$ cp <yii-analogue-clock-widget>/Clock.php <app-name>/protected/components/
$ mkdir <app-name>/protected/components/views
$ cp <yii-analogue-clock-widget>/analogue-clock.php !$

4. Configure the config file (protected/config/main.php), with inserting a following line that indicates the zii search path.

'import'=>array(
          'application.models.*',
          'application.components.*',
          'zii.widgets.*',  <<< this line
),

5. Change the layout from 'cloumn1' to 'column2' in the controller (protected/components/Controller.php).

public $layout='//layouts/column2';

6. Add a widget call in the side bar in the view file (protected/views/layouts/column2.php).

<?php $this->widget('Clock'); ?>

7. You get the clock widget in the side bar of the skeleton application as follows.

screenshot.jpg

Be the first person to leave a comment

Please to leave your comment.

Write new article
  • Written by: mocapapa
  • Category: Tutorials
  • Yii Version: 1.1
  • Votes: +1
  • Viewed: 7,042 times
  • Created on: Sep 6, 2010
  • Last updated: Sep 6, 2010