public function actionPosts()
 {
     //$post = TblPost::model()->findByPk(1);
     //$author = $post->categories;
     // print_r($author);
     //$posts = TblPost::model()->with(array('author.profile', 'categories'=>array('together' => false)));
     $count = TblPost::model()->with(array('author.profile', 'categories' => array('together' => false)))->count();
     //MyClass::dump($posts);
     //$count = TblPost::model()->with('categoryCount')->findAll();
     $criteria = new CDbCriteria();
     //$criteria->select = 'author.name as author_name';
     $criteria->with[] = 'author.profile';
     $criteria->with['categories'] = array('together' => false);
     $pages = new CPagination($count);
     $pages->pageSize = 2;
     //$pages->applyLimit($criteria);
     $sort = new CSort();
     $sort->modelClass = 'TblPost';
     $sort->attributes = array('*');
     $sort->attributes['author_username'] = array('asc' => 'author.username', 'desc' => 'author.username DESC');
     $sort->separators = array(',', '-');
     $sort->applyOrder($criteria);
     $dataProvider = new CActiveDataProvider(TblPost::model(), array('pagination' => array('pageSize' => 3, 'pageVar' => 'page'), 'sort' => $sort));
     $dataProvider->criteria = $criteria;
     $model = TblPost::model()->setDbCriteria($criteria);
     $this->render('posts', array('pages' => $pages, 'dataProvider' => $dataProvider, 'model' => $model));
 }