Skip to content

Instantly share code, notes, and snippets.

@Maxcorp
Created April 4, 2014 08:07
Show Gist options
  • Save Maxcorp/9970196 to your computer and use it in GitHub Desktop.
Save Maxcorp/9970196 to your computer and use it in GitHub Desktop.
public function actionSection($section)
{
$model = Section::model()->findByAttributes(array('vis'=>'1'),
"url_alias=:section",
array(":section"=>$section));
if(!$model || $model->pid){
throw new CHttpException(404);
}
Controller::$current_section = $model->id;
if($model->img) {
Controller::$section_img = $model->img;
}
//Установка meta-данных
$this->setMeta($model->meta_title, $model->meta_keywords, $model->meta_description, $model->name);
$model = Gallery::insertGalleries($model);
$this->breadcrumbs = array('homeLink'=>CHtml::link('Главная','/'),
'separator'=>'&nbsp;<span>•</span>&nbsp;',
'links'=>array($model->name),
'htmlOptions' => array('class' => 'b-breadcrumbs'));
$this->render('section', array('model'=>$model));
}
/*
* Разделы 2-го уровня
*/
public function actionSubsection($section, $subsection)
{
$model = Section::model()->findByAttributes(array('vis'=>'1'),
"url_alias=:subsection",
array(":subsection"=>$subsection));
if(empty($model) || empty($model->_parent) || ($section != $model->_parent->url_alias)) {
throw new CHttpException(404);
}
Controller::$current_section = $model->id;
//Установка meta-данных
$this->setMeta($model->meta_title, $model->meta_keywords, $model->meta_description, $model->name);
$model = Gallery::insertGalleries($model);
$this->breadcrumbs = array('homeLink'=>CHtml::link('Главная','/'),
'separator'=>'&nbsp;<span>•</span>&nbsp;',
'links'=>array($model->_parent->name=>array("/{$model->_parent->url_alias}/"),
$model->name),
'htmlOptions' => array('class' => 'b-breadcrumbs'));
$this->render('section', array('model'=>$model));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment