Exemplo n.º 1
0
 public function onGeneratePage($objPage, $objLayout, $objPageRegular)
 {
     if (\Input::get('category')) {
         $objCategory = \ShopCategoryModel::findByAlias(\Input::get('category'));
         if (trim($objCategory->cssClass)) {
             $objLayout->cssClass .= $objCategory->cssClass . ' ';
         }
     }
 }
 protected function compile()
 {
     foreach ($this->trail as $id) {
         $item = \ShopCategoryModel::findById($id);
         switch ($item->type) {
             case "category":
                 $pageId = $this->acquisto_jumpTo;
                 $pageAdd = '/category/' . $item->alias;
                 break;
             case "redirect":
                 $objRedirect = \ShopCategoryModel::findById($item['categoryJump']);
                 $pageId = $this->acquisto_jumpTo;
                 $pageAdd = '/category/' . $objRedirect->alias;
                 break;
             case "page":
                 $pageId = $item->jumpTo;
                 $pageAdd = '';
                 break;
             default:
                 if (isset($GLOBALS['TL_HOOKS']['modifyOwnCategoryTyp']) && is_array($GLOBALS['TL_HOOKS']['modifyOwnCategoryTyp'])) {
                     foreach ($GLOBALS['TL_HOOKS']['modifyOwnCategoryTyp'] as $callback) {
                         $this->import($callback[0]);
                         $item = $this->{$callback}[0]->{$callback}[1]($item);
                     }
                 }
                 $blnHook = true;
                 break;
         }
         if (!$blnHook) {
             $objPage = $this->Database->prepare("SELECT id, alias FROM tl_page WHERE id=?")->limit(1)->execute($pageId);
             $item->href = \Controller::generateFrontendUrl($objPage->row(), $pageAdd);
         }
         if ($item->cssClass) {
             $item->css = $item->cssClass;
         }
         if ($this->showHidden && $item->hide or !$item->hide) {
             $items[] = $item;
         }
     }
     $items[0]->css = trim($items[0]->css . ' first');
     $items[count($items) - 1]->css = trim($items[count($items) - 1]->css . ' active last');
     $items[count($items) - 1]->href = '';
     $this->Template->items = $items;
 }
 public function renderCategory($items = array(), $level = 1)
 {
     $objPage = $this->Database->prepare("SELECT id, alias FROM tl_page WHERE id=?")->limit(1)->execute($this->acquisto_jumpTo);
     $strUrl = \Controller::generateFrontendUrl($objPage->fetchAssoc(), '/category/%s');
     if (count($items) > 1) {
         $items[0]['css'] .= 'first ';
         $items[count($items) - 1]['css'] .= 'last ';
     } else {
         $items[0]['css'] .= 'only ';
     }
     foreach ($items as $item) {
         $item = (object) $item;
         if ($item->subitems) {
             $item->subitems = $this->renderCategory($item->subitems, $level + 1);
             $item->css .= 'submenu ';
         }
         if ($this->trail[$level - 1] == $item->id) {
             if ($this->trail[$level - 1] == end($this->trail)) {
                 $item->css .= 'active ';
             } else {
                 $item->css .= 'trail ';
             }
         }
         switch ($item->type) {
             case "category":
                 $pageId = $this->acquisto_jumpTo;
                 $pageAdd = '/category/' . $item->alias;
                 break;
             case "redirect":
                 $objRedirect = \ShopCategoryModel::findById($item->categoryJump);
                 $pageId = $this->acquisto_jumpTo;
                 $pageAdd = '/category/' . $objRedirect->alias;
                 break;
             case "page":
                 $pageId = $item->jumpTo;
                 $pageAdd = '';
                 break;
             default:
                 if (isset($GLOBALS['TL_HOOKS']['modifyOwnCategoryTyp']) && is_array($GLOBALS['TL_HOOKS']['modifyOwnCategoryTyp'])) {
                     foreach ($GLOBALS['TL_HOOKS']['modifyOwnCategoryTyp'] as $callback) {
                         $this->import($callback[0]);
                         $item = $this->{$callback}[0]->{$callback}[1]($item);
                     }
                 }
                 $blnHook = true;
                 break;
         }
         if (!$blnHook) {
             $objPage = $this->Database->prepare("SELECT id, alias FROM tl_page WHERE id=?")->limit(1)->execute($pageId);
             $item->href = \Controller::generateFrontendUrl($objPage->row(), $pageAdd);
         }
         $item->css = trim(trim($item->css) . ' ' . trim($item->cssClass));
         $index[] = $item;
     }
     $objTemplate = new \FrontendTemplate('category_node');
     $objTemplate->items = $index;
     $objTemplate->level = $level;
     return $objTemplate->parse();
 }