/** * First get all of the enabled pages and their labels and links. Then * determine how the menu link should be shown if shown at all, based on * the number of enabled menus or the number of enabled menu items. * * @return array */ public function getNavigationLinks() { $sql = "SELECT about.`status` as about,\n about.`title` as about_title,\n contact.`status` as contact,\n contact.`title` as contact_title,\n catering.`status` as catering,\n catering.`title` as catering_title,\n happy_hour.`status` as happy_hour,\n happy_hour.`title` as happy_hour_title\n FROM `about_page` about\n JOIN `contact_page` contact\n ON contact.`business_id` = about.`id`\n JOIN `catering_page` catering\n ON catering.`business_id` = about.`id`\n JOIN `happy_hour_page` happy_hour\n ON happy_hour.`business_id` = about.`id`\n WHERE about.`id` = '" . $this->business_id . "'"; $rows = $this->db->query($sql); $return_array = array(); $page_keys = array('about', 'contact', 'catering', 'happy_hour'); foreach ($page_keys as $page_key) { if ($rows[0][$page_key]) { $return_array[] = array('slug' => $page_key, 'label' => $rows[0][$page_key . '_title']); } } $menu = new Menu($this->db, $this->business_id); if ($menus = $menu->getCollection()) { if (count($menus) == 1) { $return_array_menu = array('slug' => 'menu', 'label' => 'Menu'); } else { $children = array(); foreach ($menus as $menu) { $children[] = array('slug' => 'menus/' . $menu['slug'], 'label' => $menu['name']); } $return_array_menu = array('slug' => '#', 'label' => 'Menus', 'children' => $children); } } elseif ($menu_items = $menu->getItemCollection()) { $return_array_menu = array('slug' => 'menu', 'label' => 'Menu'); } if (isset($return_array_menu)) { array_unshift($return_array, $return_array_menu); } return $return_array; }
public function index($parameters) { if (!$parameters || count($parameters) > 1) { $this->loadView('404'); } $menu_slug = $parameters[0]; $menu = new Menu($this->db, $this->business['id']); $menu_data = $menu->getDataFromSlug($menu_slug); if (!$menu_data) { $this->loadView('404'); } $this->menu = $menu_data; $this->menu_items = $menu->getLoadedItemCollectionByMenuId($menu_data['id']); $this->loadView('menu'); }
public function index($parameters) { if ($parameters) { $this->loadView('404'); } $menu = new MenuModel($this->db, $this->business['id']); $menus = $menu->getCollection(); if (count($menus) > 1) { $this->loadView('404'); } $this->menu_items = $menu->getLoadedItemCollection(); if (!$this->menu_items) { $this->loadView('404'); } $this->loadView('menu'); }