public function _editContent($id) { App::uses('WebpageMenu', 'Webpages.Model'); $WebpageMenu = new WebpageMenu(); $this->set('menus', $WebpageMenu->find('list', array('fields' => array('WebpageMenu.code', 'WebpageMenu.name'), 'conditions' => array('WebpageMenu.parent_id' => null)))); $this->set('parents', $this->Webpage->find('list', array('conditions' => array('Webpage.parent_id' => null, 'Webpage.type' => array('content', 'section'))))); // required to have easy template settings $this->set('templates', $this->Webpage->find('list', array('conditions' => array('Webpage.type' => 'template', 'Webpage.is_default' => 0)))); $defaultTemplate = $this->Webpage->find('list', array('conditions' => array('Webpage.type' => 'template', 'Webpage.is_default' => 1))); $defaultTemplate[key($defaultTemplate)] .= ' (default)'; $this->set(compact('defaultTemplate')); }
/** * Menu method * Create a new menu for a user specific case for menu creation during build * */ public function menu() { App::uses('UserRole', 'Users.Model'); $UserRole = new UserRole(); $userRoles = $UserRole->find('list'); $text = __('%s Dashboard', Inflector::humanize($userRoles[$this->request->data['WebpageMenu']['user_role_id']])); $this->request->data['WebpageMenu']['name'] = $text; $this->request->data['WebpageMenu']['parent_id'] = null; $this->request->data['WebpageMenu']['item_text'] = $text; App::uses('WebpageMenu', 'Webpages.Model'); $WebpageMenu = new WebpageMenu(); $WebpageMenu->create(); if ($WebpageMenu->save($this->request->data)) { $this->Session->setFlash(__('New flow started')); $this->redirect($this->referer()); } else { $this->Session->setFlash(__('Save failure. Please, try again.')); $this->redirect($this->referer()); } }