summaryrefslogtreecommitdiff
path: root/protected
diff options
context:
space:
mode:
authorPatrick Seeger <pseeger@ccwn.org>2012-05-18 23:49:50 +0200
committerPatrick Seeger <pseeger@ccwn.org>2012-05-18 23:49:50 +0200
commit8f75b966aa7376e2febe42f0d39257a8b3eec667 (patch)
treea20e255e9d4e749a44811c7b6e525b9c112f2270 /protected
parent06d036c59abbca0b851dd2d820cf57f51514e86d (diff)
menustruktur optimiert
Diffstat (limited to 'protected')
-rw-r--r--protected/config/main.php6
-rw-r--r--protected/modules/cms/controllers/SitecontentController.php4
-rw-r--r--protected/modules/cms/models/Sitecontent.php16
3 files changed, 19 insertions, 7 deletions
diff --git a/protected/config/main.php b/protected/config/main.php
index 653a119..87266e5 100644
--- a/protected/config/main.php
+++ b/protected/config/main.php
@@ -91,9 +91,9 @@ return array(
),
// uncomment the following to show log messages on web pages
-// array(
-// 'class'=>'CWebLogRoute',
-// ),
+ array(
+ 'class'=>'CWebLogRoute',
+ ),
),
),
diff --git a/protected/modules/cms/controllers/SitecontentController.php b/protected/modules/cms/controllers/SitecontentController.php
index e4f7a5f..43fb74b 100644
--- a/protected/modules/cms/controllers/SitecontentController.php
+++ b/protected/modules/cms/controllers/SitecontentController.php
@@ -42,8 +42,10 @@ class SitecontentController extends Controller
$model = $this->loadContent();
$this->breadcrumbs = array($model->title);
- if($model->id > 1) {
+ if($model->depth == 1) {
$this->menu = CMS::getMenuPoints($model->id);
+ } elseif ($model->depth == 2){
+ $this->menu = CMS::getMenuPoints($model->oparent->id);
}
$this->render('view', array(
'sitecontent' => $model,
diff --git a/protected/modules/cms/models/Sitecontent.php b/protected/modules/cms/models/Sitecontent.php
index 6d8def2..bcd1385 100644
--- a/protected/modules/cms/models/Sitecontent.php
+++ b/protected/modules/cms/models/Sitecontent.php
@@ -27,8 +27,8 @@ class Sitecontent extends CActiveRecord
public function rules()
{
return array(
- array('position, title, language', 'required'),
- array('parent, position, createtime, updatetime', 'numerical', 'integerOnly'=>true),
+ array('position, title, language, depth', 'required'),
+ array('parent, depth, position, createtime, updatetime', 'numerical', 'integerOnly'=>true),
array('title, keywords, description', 'length', 'max'=>255),
array('content, title_url, title_browser', 'safe'),
array('title, keywords, description, content, language', 'safe', 'on'=>'search'),
@@ -38,7 +38,7 @@ class Sitecontent extends CActiveRecord
public function relations()
{
return array(
- 'parent' => array(self::BELONGS_TO, 'Sitecontent', 'parent'),
+ 'oparent' => array(self::BELONGS_TO, 'Sitecontent', 'parent'),
'childs' => array(self::HAS_MANY, 'Sitecontent', 'parent'),
);
}
@@ -57,6 +57,7 @@ class Sitecontent extends CActiveRecord
'createtime' => Yii::t('CmsModule.cms', 'Createtime'),
'updatetime' => Yii::t('CmsModule.cms', 'Updatetime'),
'language' => Yii::t('CmsModule.cms', 'Language'),
+ 'depth' => Yii::t('CmsModule.cms', 'Depth'),
);
}
@@ -74,9 +75,18 @@ class Sitecontent extends CActiveRecord
$criteria->compare('authorid',$this->authorid);
$criteria->compare('createtime',$this->createtime);
$criteria->compare('updatetime',$this->updatetime);
+ //$criteria->compare('depth',$this->depth);
return new CActiveDataProvider('Sitecontent', array(
'criteria'=>$criteria,
));
}
+
+ public function beforeSave() {
+ if ($this->parent > 0){
+ $this->depth = $this->oparent->depth + 1;
+
+ }
+ return parent::beforeSave();
+ }
}