public function actionIndex() { //Общий список категорий вопросов $root = BeforeAfterRubrics::getRoot(new BeforeAfterRubrics()); $model = array(); $model['group'] = null; $model['sub_group'] = $root->descendants(1)->findAll($root->id); $this->render('index', array('model' => $model)); }
/** * Manages all models. */ public function actionIndex() { $model = new BeforeAfterElements('search'); $model->attachBehavior('dateComparator', array('class' => 'DateComparator')); $model->unsetAttributes(); // clear any default values // set attributes from get if (isset($_GET['BeforeAfterElements'])) { $model->attributes = $_GET['BeforeAfterElements']; } $root = BeforeAfterRubrics::getRoot(new BeforeAfterRubrics()); $catalog = $root->descendants()->findAll($root->id); $this->render('list', array('model' => $model, 'root' => $root, 'catalog' => $catalog)); }
/** * Manages all models. */ public function actionIndex($id = null) { $this->breadcrumbs = array('До и После' => array('/beforeafter/beforeafterrubrics/index')); set_time_limit(0); //получаем URL $base_patch = SITE_NAME_FULL . '/beforeafter'; if (!empty($id)) { $model = BeforeAfterRubrics::model()->findByPk((int) $id); if ($model) { $i = (int) $id; $array = array(); do { $model = BeforeAfterRubrics::model()->findByPk((int) $i); if (isset($model->id)) { $array[] = $model->id; } $i = (int) $model->parent_id; } while ($i != 0); $array = array_reverse($array); unset($array[0]); foreach ($array as $value) { $base_patch .= '/' . BeforeAfterRubrics::model()->findByPk((int) $value)->url; } } } if (!empty($id)) { $model = BeforeAfterRubrics::model()->findByPk((int) $id); $root = BeforeAfterRubrics::getRoot($model); $category = BeforeAfterRubrics::model()->findByPk((int) $id); //Получаем нужный узел $descendants = $category->descendants(1)->findAll(); $param[] = 'left_key > ' . $model->left_key . ' AND right_key < ' . $model->right_key; } else { $model = new BeforeAfterRubrics(); $category = BeforeAfterRubrics::getRoot($model); $category = BeforeAfterRubrics::model()->findByPk($category->id); $descendants = $category->descendants(1)->findAll(); $root = ""; $param[] = 'level=2'; } $model = new BeforeAfterRubrics(); $param = implode(" AND ", $param); $data = array('criteria' => array('condition' => $param)); $data['sort'] = array('defaultOrder' => 'left_key ASC'); if ($settingsModel = SiteModuleSettings::model()->find('site_module_id = 12')) { $data['Pagination'] = array('PageSize' => (int) $settingsModel->elements_page_admin > 0 ? $settingsModel->elements_page_admin : 100); } $provider = new CActiveDataProvider('BeforeAfterRubrics', $data); $provider->criteria = $model->search($param); $this->render('list', array('model' => $model, 'provider' => $provider, 'root' => $root, 'categories' => $descendants, 'base_patch' => $base_patch)); }