I use CActiveDataprovider to display data from different tables. Now I have a problem. I have two tables (elements and categories) and both of them have priority_order columns, and I need to show the data using the order on both columns.
For example: there are two categories and six elements related to these categories:
- Food (priority_order 1)
- food_item1 (priority_order 1)
- fodd_item2 (priority_order 2)
- fodd_item3 (priority_order 3)
- Drink (priority_order 2)
- drink_item1 (priority_order 1)
- drink_item2 (priority_order 2)
- drink_item3 (priority_order 3)
Now I need to show the data in the CGridView just like they are in the order above. All products will be in first place and will be sorted by their priority, and goods for drinking will come later; obviously in their order.
In ItemsController I am trying to make the code below (now only by categories)
$dataProvider = new CActiveDataProvider('Items', array( 'criteria' => array( 'with' => array('category'), 'condition' => 'user_id=' . Yii::app()->user->id,
I would be happy to provide more detailed information, if still not clear enough. Any help would be appreciated.
source share