public function actionIndex() { $this->title = 'Tin tức'; // $page = Yii::app()->getParam("page"); // // $criteria = new CDbCriteria(); $criteria->condition = 'taxonomy_id = :id'; $criteria->order = 'id DESC'; $criteria->params = array(':id' => 1); // // $item_count = Category::model()->count($criteria); // $pages = new CPagination($item_count); // $pages->setPageSize(5); // $pages->applyLimit($criteria); // the trick is here! $of = array(); // $of['model'] = Category::model()->findAll($criteria); // $of['item_count'] = $item_count; // $of['page_size'] = 1; // $of['pages'] = $pages; // // $criteria->limit = 10; $data = Category::model()->findAll($criteria); $total = 0; foreach ($data as $k => $v) { if (Libraries::isEnable($v->id)) { $total++; } } $this->render('index', array('category' => $data, 'total' => $total, 'page' => $of)); }
public function actionIndex() { $this->title = 'Học offline'; $criteria = new CDbCriteria(); $criteria->addCondition(array('taxonomy_id = :cid', 'state = :stt')); $criteria->params = array(':cid' => 8, ':stt' => 1); $data = Category::model()->findAll($criteria); $total = 0; foreach ($data as $k => $v) { if (Libraries::isEnable($v->id)) { $total++; } } $this->render('index', array('category' => $data, 'total' => $total)); }
<img src="<?php echo Yii::app()->getBaseUrl(true); ?> /themes/default/assets/img/image-sub.png"> </div> </div> <div id='wrap-en' class='row-fluid'> <div class="span9" id='wrap-body'> <div class='row-fluid header-at'> </div><!-- end header-at--> <div class='row-fluid body-at container'> <div id="en-left" class="span6 pag2"> <?php $i = 0; foreach ($category as $row) { if (Libraries::isEnable($row->id)) { $i++; ?> <div class="en-box row-fluid"> <div class="row-fluid en-box-title"> <?php echo "<a class='title_cate' href='" . Yii::app()->getBaseUrl(true) . "/tham-khao/" . $row->slug . "-" . $row->id . ".html'>" . $row->title . "</a>"; ?> </div> <?php $this->widget('sub_news', array('cat_id' => $row->id, 'type' => 'listen', 'slug' => 'tham-khao')); ?> </div><!-- end .en-box //ngu phap --> <?php if ($i == round($total / 2)) { echo "</div>";