controller 部份
[sourcecode language=’php’]
$sort->attributes= array(
‘product.id’=>’productId’,
‘product.name’=>’productName’,
‘category.name’=>’categoryName’,
‘brand.name’ => ‘brandName’,
);
/*
$sort->attributes= array(
‘model中的alias.欄位’=>’網址顯示的Alias’,
);
*/
[/sourcecode]
view 部份
[sourcecode language=’php’]
< ?php echo $sort->link(‘product.id’,’編號’); ?>
//< ?php echo $sort->link(‘table.name’,’網頁顯示的名稱’); ?>
[/sourcecode]
model 部份
記得把 relations中的 alias 設好
如下
[sourcecode language=’php’]
/**
* @return array relational rules.
*/
public function relations()
{
return array(
‘brand’=>array(self::BELONGS_TO,’brand’,’brand_id’, ‘alias’=>’brand’),
‘category’=>array(self::BELONGS_TO,’category’,’category_id’, ‘alias’=>’category’),
‘series’=>array(self::BELONGS_TO,’series’,’series_id’,’alias’=>’series’),
);
}
[/sourcecode]