コード例 #1
0
ファイル: Products.php プロジェクト: hosivan90/toxotes
 public function executeDetail()
 {
     $id = $this->get('id');
     if (!$id || !($item = \Items::retrieveById($id))) {
         return $this->raise404(t('Product Category not found!'));
     }
     $term = $item->getCat();
     $this->setView('Products/item_detail');
     $this->view()->assign(['item' => $item, 'term' => $term]);
     return $this->renderComponent();
 }
コード例 #2
0
ファイル: FrontendBase.php プロジェクト: hosivan90/toxotes
 public function beforeExecute()
 {
     parent::beforeExecute();
     // TODO: Change the autogenerated stub
     $document = $this->document();
     $document->title = \Setting::get('site_name');
     $this->_initTemplate();
     $this->_initLanguages();
     Plugin::addFilter('custom_router_param', function ($route, $params) {
         if ('products/category' == $route) {
             if (isset($params['id']) && ($term = \Terms::retrieveById($params['id']))) {
                 $params['slug'] = $term->getSlug();
             }
         }
         if ('products/detail' == $route) {
             if (isset($params['id']) && ($item = \Items::retrieveById($params['id']))) {
                 $params['slug'] = $item->getSlug();
             }
         }
         return $params;
     }, 1, 2);
 }