Friday, February 22, 2013

YII: How to Customize the Admin action

If you want to add condition, you can do the following: 

1) copy-paste your action and change only name of it, for example "actionList"
2) change 2 lines of method search in your model to

public function search($param = array())
{
  $criteria=new CDbCriteria($param);
.....................................

3) copy-paste your admin view and rename it to "list" then open it and change line
'dataProvider'=>$model->search(),

to


'dataProvider'=>$model->search(array('condition'=>'column_name=1')),
 
// Added by me 
4) Or if you want to just use same "admin" view page, you can just add a variable:
 
                $this->render('admin',array(
   'model'=>$model, 'condition'=>$condition,
  ));
 
And in the admin view page, you can 
change it as below. 
'dataProvider'=>$model->search(array('condition'=>$condition)),
 
 
Reference:
http://www.yiiframework.com/forum/index.php/topic/13079-customising-the-admin-action-created-by-crud/
 

Secure your website with JavaScript, NO RIGHT CLICK

No right click code for images. Block your visitors from right clicking on your website pages with 'no right click for source'. Disable "copy and paste" to protect your websites source code!

http://www.hypergurl.com/norightclick.html

Error Fix: Delete Action Calls for Get Request in YII CGridView

Error Fix: Delete Action Calls for Get Request in YII CGridView

Suddenly, I noticed that delete button in YII CGridView didn't work.

Yii::app()->request->isPostRequest would return false, which means that variables were passed through $_GET request.

After checking FireBug js error, I had to update jquery.ba-bbq.js file and jquery.yiigridview.js file and updated jquery.js just in case.

https://github.com/yiisoft/yii/issues/2069

http://code.google.com/p/zii/source/browse/trunk/widgets/assets/gridview/jquery.yiigridview.js?r=208


Be sure to delete the specific folder that saved the javascript file in assets folder to delete the cache.
Everything is working fine after that~

Friday, February 15, 2013

Installing Drupal

To install Drupal:

1. Download latest stable version of Drupal
2. Upload them to the directory that you want to install
3. Extract the tar.gz or zip file to the directory
4. Move one directory up because the tar.gz or zip file would be extracted in one directory
5. Copy /sites/default/default.settings.php and change default.settings.php (you would see two files inside /sites/default/ folder - default.settings.php and settings.php)
6. Modify file permission for settings.php
7. Run install
8. Change permission for settings.php and other folders as directed by Drupal
  • /default on 755
  • /default/files including all subfolders and files on 744 (or 755)
  • /themes including all subfolders and files on 755
  • /modules including all subfolders and files on 755
  • /default/settings.php and /default/default.settings.php on 444

That's it~