Example #1
0
 public function display($cachable = false, $urlparams = false)
 {
     $search_params = $this->search_params;
     $items = $this->items;
     // Get site params for the current application
     $params = $this->application->getParams('site');
     if (count($items) == 1 && $search_params->get('redirect_if_one')) {
         $item = array_pop($items);
         $link = JRoute::_('index.php?option=com_zoo&task=item&item_id=' . $item->id, false);
         JFactory::getApplication()->redirect($link);
     }
     // Pepare the view
     $view = new AppView(array('name' => 'category'));
     $layout = strlen($search_params->get('page_layout')) ? $search_params->get('page_layout') : 'search';
     // JSON support
     if (JRequest::getVar('format', '') == 'json') {
         $layout = 'json';
     }
     $item_layout = $search_params->find('zoofilter.item_layout', $search_params->get('layout'));
     $view->addTemplatePath($this->app->path->path('zoofilter:layouts'));
     $view->addTemplatePath($this->application->getTemplate()->getPath());
     // override by App
     $view->setLayout($layout);
     // Add the necessary variables for the view
     $view->app = $this->app;
     $view->items = $items;
     $view->application = $this->application;
     $view->item_layout = $item_layout;
     $item_ids = array();
     foreach ($items as $item) {
         $item_ids[] = $item->id;
     }
     // get item pagination
     $items_per_page = $search_params->get('items_per_page');
     $page = JRequest::getVar('page', 1);
     $view->pagination = $this->app->pagination->create($this->itemsTotal, $page, $items_per_page, 'page', 'app');
     $view->pagination->setShowAll($items_per_page == 0);
     $uri = JURI::getInstance();
     $uri->setVar('page', null);
     $view->total = $this->itemsTotal;
     $view->pagination_link = $uri->toString();
     // set template and params
     $view->assign('template', $this->application->getTemplate());
     $view->params = $params;
     $view->assign('search_params', $search_params);
     // set renderer
     $uri = JURI::getInstance();
     $permalink = $uri->toString(array('scheme', 'host', 'port')) . JRoute::_('index.php?option=com_zoo&controller=zoofilter&task=dosearch&app_id=' . $this->application->id . '&search_id=' . $this->search_id);
     $view->show_permalink = $search_params->get('show_permalink');
     $view->permalink = $permalink;
     $view->app_id = $this->application->id;
     $view->search_id = $this->search_id;
     $view->show_title = $search_params->get('show_title');
     $view->show_ordering = $search_params->get('show_ordering');
     $view->columns = $search_params->get('columns');
     $view->page_title = $search_params->get('page_title');
     $view->renderer = $this->app->renderer->create('item');
     $view->renderer->addPath(array($this->app->path->path('component.site:'), $this->application->getTemplate()->getPath(), $this->app->path->path('zoofilter:')));
     // Add ordering
     $this->app->path->register($this->app->path->path('zoofilter:ordering/renderer'), 'renderer');
     $order_renderer = $this->app->renderer->create('ordering')->addPath(array($this->app->path->path('zoofilter:ordering')));
     $elements_layout = $search_params->get('ordering_layout');
     $type = $this->application->getType($search_params->get('type'));
     $order_elements = $order_renderer->render('item.' . $elements_layout, compact('type'));
     $view->assign('order_elements', $order_elements);
     // display view
     $view->display();
 }