public function createPath() { $path = SnapFormat::slugify($this->title); $Parent = $this->Parent; while ($Parent) { $path = SnapFormat::slugify($Parent->title) . '/' . $path; $Parent = $Parent->Parent; } return '/' . $path; }
public function beforeSave() { if (empty($this->path)) { $mainMenu = SnapUtil::config('general/site.default_menu'); $MI = MenuItem::model()->findByAttributes(array('menu_id' => $mainMenu, 'content_id' => $this->id)); if ($MI && !empty($this->id)) { $this->path = $MI->createPath(); } else { $this->path = '/' . $this->type . '/' . $this->title; } } $this->path = SnapFormat::slugify($this->path); return parent::beforeSave(); }