Example #1
0
 /**
  * Assign breadcrumbs to the template.
  *
  * @return null
  */
 protected function generate_breadcrumbs()
 {
     $category = new \titania_category();
     // Parents
     foreach (array_reverse($this->cache->get_category_parents($this->id)) as $row) {
         $category->__set_array($this->categories[$row['category_id']]);
         $this->display->generate_breadcrumbs(array($category->get_name() => $category->get_url()));
     }
     // Self
     $this->display->generate_breadcrumbs(array($this->category->get_name() => $this->category->get_url()));
 }
Example #2
0
 /**
  * Display categories
  *
  * @param int $parent_id			The parent id (only show categories under this category)
  * @param string $blockname 		The name of the template block to use (categories by default)
  * @param bool $is_manage			Whether the categories are being displayed in management page. Defaults to false.
  * @param bool $display_full_tree	Whether to display the full category tree.
  */
 public function display_categories($parent_id = 0, $blockname = 'categories', $is_manage = false, $display_full_tree = false, array $params = array())
 {
     $categories = $this->cache->get_categories();
     $category = new \titania_category();
     $active_parents = array();
     if ($parent_id) {
         $active_parents = $this->cache->get_category_parents($parent_id);
         $active_parents = $active_parents ? array_keys($active_parents) : array();
         $active_parents[] = $parent_id;
     }
     foreach ($categories as $data) {
         $category->__set_array($data);
         $ignore = !$is_manage && !$category->category_visible || !$display_full_tree && $parent_id != $category->parent_id;
         if ($ignore) {
             continue;
         }
         $active = in_array($category->category_id, $active_parents) || in_array($category->parent_id, $active_parents);
         $this->template->assign_block_vars($blockname, array_merge($category->assign_display(true), array('ACTIVE' => $active, 'U_VIEW_CATEGORY' => $category->get_url($params))));
     }
 }