public function display($tpl = null) { $this->option = JFactory::getApplication()->input->get('option'); $this->items = $this->get('Items'); $this->state = $this->get('State'); $this->pagination = $this->get('Pagination'); $this->params = $this->state->get('params'); $this->displayProjectsNumber = $this->params->get('categories_display_projects_number', 0); $this->numberInRow = $this->params->get('categories_categories_row', 3); // Get description length $this->descriptionLength = $this->params->get('categories_description_length', 128); // Load projects number. if ($this->displayProjectsNumber) { $ids = array(); foreach ($this->items as $item) { $ids[] = $item->id; } $categories = new Crowdfunding\Categories(); $categories->setDb(JFactory::getDbo()); $this->projectsNumber = $categories->getProjectsNumber($ids, array('state' => Prism\Constants::PUBLISHED, 'approved' => Prism\Constants::APPROVED)); } // Prepare items parameters. if (is_array($this->items)) { $this->items = CrowdfundingHelper::prepareCategories($this->items, $this->numberInRow); } // Get layout $layout = $this->params->get('categories_layout', 'grid'); $this->templateView = in_array($layout, $this->allowedLayouts, true) ? $layout : 'grid'; // Get params /** @var $params Joomla\Registry\Registry */ $params = $this->state->get('params'); $this->params = $params; // Prepare filters $this->listOrder = $this->escape($this->state->get('list.ordering')); $this->listDirn = $this->escape($this->state->get('list.direction')); $this->saveOrder = strcmp($this->listOrder, 'a.ordering') === 0; $this->prepareDocument(); parent::display($tpl); }
private function prepareSubcategories() { $app = JFactory::getApplication(); $categoryId = $app->input->getInt("id"); $categories = new Crowdfunding\Categories(); $category = $categories->get($categoryId); $this->categories = $category->getChildren(); $this->subcategoriesPerRow = $this->params->get("categories_items_row", 3); $this->displayProjectsNumber = $this->params->get("categories_display_projects_number", 0); // Load projects number. if ($this->displayProjectsNumber) { $ids = array(); foreach ($this->items as $item) { $ids[] = $item->id; } $categories->setDb(JFactory::getDbo()); $this->projectsNumber = $categories->getProjectsNumber($ids, array("state" => 1)); } $this->categories = CrowdfundingHelper::prepareCategories($this->categories); }