/** * Load the data, don't forget to validate the incoming data */ private function getData() { // requested page $requestedPage = $this->URL->getParameter('page', 'int', 1); // set URL and limit $this->pagination['url'] = FrontendNavigation::getURLForBlock('catalog'); $this->pagination['limit'] = FrontendModel::getModuleSetting('catalog', 'overview_num_items', 10); // populate count fields in pagination $this->pagination['num_items'] = FrontendCatalogModel::getAllCount(); $this->pagination['num_pages'] = (int) ceil($this->pagination['num_items'] / $this->pagination['limit']); // num pages is always equal to at least 1 if ($this->pagination['num_pages'] == 0) { $this->pagination['num_pages'] = 1; } // redirect if the request page doesn't exist if ($requestedPage > $this->pagination['num_pages'] || $requestedPage < 1) { $this->redirect(FrontendNavigation::getURL(404)); } // populate calculated fields in pagination $this->pagination['requested_page'] = $requestedPage; $this->pagination['offset'] = $this->pagination['requested_page'] * $this->pagination['limit'] - $this->pagination['limit']; // get all categories $this->categories = FrontendCatalogModel::getAllCategories(); // get tree of all categories $this->categoriesTree = FrontendCatalogModel::getCategoriesTree(); // get all products $this->products = FrontendCatalogModel::getAll($this->pagination['limit'], $this->pagination['offset']); }
/** * Parse */ private function parse() { // get categories $categories = FrontendCatalogModel::getAllCategories(); $count = 0; // any categories? if (!empty($categories)) { // build link $link = FrontendNavigation::getURLForBlock('Catalog', 'Category'); // loop and reset url foreach ($categories as $key => &$row) { if ($row['parent_id'] > 0 || $count >= 4) { unset($categories[$key]); continue; } //--Create url $row['url'] = $link . '/' . $row['url']; //--Get image $row['image'] = FrontendMediaHelper::getFromModule('Catalog', $row['id'], 0, 1, 'category'); //--add count $count++; } } // assign comments $this->tpl->assign('categories', $categories); }
/** * Parse */ private function parse() { // get categories $categories = FrontendCatalogModel::getAllCategories(); // get tree of all categories $tree = FrontendCatalogModel::getCategoriesTree(); // any categories? if (!empty($categories)) { // build link $link = FrontendNavigation::getURLForBlock('Catalog', 'Category'); // loop and reset url foreach ($categories as &$row) { $row['url'] = $link . '/' . $row['url']; } } // assign comments $this->tpl->assign('widgetCatalogCategoriesFlat', $categories); $this->tpl->assign('widgetCatalogCategoriesTree', $tree); }
/** * Parse the page */ protected function parse() { // add css $this->header->addCSS('/src/Frontend/Modules/' . $this->getModule() . '/Layout/Css/catalog.css'); // add noty js $this->header->addJS('/src/Frontend/Modules/' . $this->getModule() . '/Js/noty/packaged/jquery.noty.packaged.min.js'); // add breadcrumbs $categories = FrontendCatalogModel::getAllCategories(); $paths = FrontendCatalogModel::traverseUp($categories, $this->record); $baseUrl = FrontendNavigation::getURLForBlock('Catalog', 'Category'); // get full urls $parentCategories = array(); foreach ($paths as $key => $value) { $category = FrontendCatalogModel::getCategoryById($key); $breadcrumbPaths = FrontendCatalogModel::traverseUp($categories, $category); $url = implode('/', $breadcrumbPaths); $category['full_url'] = $baseUrl . '/' . $url; // add breadcrumb $this->breadcrumb->addElement($category['title'], $category['full_url']); $parentCategories[] = array('title' => $category['title']); } if (!empty($parentCategories)) { unset($parentCategories[count($parentCategories) - 1]); } if (!empty($parentCategories)) { $this->tpl->assign('parentCategories', $parentCategories); } // hide action title $this->tpl->assign('hideContentTitle', true); // show the title $this->tpl->assign('title', $this->record['title']); // set meta $this->header->setPageTitle($this->record['meta_title'], $this->record['meta_title_overwrite'] == 'Y'); $this->header->addMetaDescription($this->record['meta_description'], $this->record['meta_description_overwrite'] == 'Y'); $this->header->addMetaKeywords($this->record['meta_keywords'], $this->record['meta_keywords_overwrite'] == 'Y'); // advanced SEO-attributes if (isset($this->record['meta_data']['seo_index'])) { $this->header->addMetaData(array('name' => 'robots', 'content' => $this->record['meta_data']['seo_index'])); } if (isset($this->record['meta_data']['seo_follow'])) { $this->header->addMetaData(array('name' => 'robots', 'content' => $this->record['meta_data']['seo_follow'])); } // assign items $this->tpl->assign('products', $this->products); $this->tpl->assign('record', $this->record); // flat array of categories $this->tpl->assign('subcategoriesFlat', $this->subcategories); // multidimensional array of categories $this->tpl->assign('subcategoriesTree', $this->subcategoriesTree); $this->tpl->assign('categoriesTree', $this->categoriesTree); // multidimensional html list of subcategories $this->tpl->assign('subcategoriesHTML', FrontendCatalogModel::getTreeHTML($this->subcategoriesTree)); // parse the pagination $this->parsePagination(); }
/** * Parse the page */ protected function parse() { $this->frmContact->parse($this->tpl); // add css $this->header->addCSS('/src/Frontend/Modules/' . $this->getModule() . '/Layout/Css/catalog.css'); // add noty js $this->header->addJS('/src/Frontend/Modules/' . $this->getModule() . '/Js/noty/packaged/jquery.noty.packaged.min.js'); // add breadcrumbs for the categories $categories = FrontendCatalogModel::getAllCategories(); $category = FrontendCatalogModel::getCategoryById($this->record['category_id']); $paths = FrontendCatalogModel::traverseUp($categories, $category); $baseUrl = FrontendNavigation::getURLForBlock('Catalog', 'Category'); // get full urls $parentCategories = array(); foreach ($paths as $key => $value) { $category = FrontendCatalogModel::getCategoryById($key); $breadcrumbPaths = FrontendCatalogModel::traverseUp($categories, $category); $url = implode('/', $breadcrumbPaths); $category['full_url'] = $baseUrl . '/' . $url; // add breadcrumb $this->breadcrumb->addElement($category['title'], $category['full_url']); $parentCategories[] = $category['title']; } if (!empty($parentCategories)) { $parentCategories = array_reverse($parentCategories); $this->tpl->assign('parentCategories', implode(' - ', $parentCategories)); } // add into breadcrumb $this->breadcrumb->addElement($this->record['meta_title']); // hide action title $this->tpl->assign('hideContentTitle', true); // show title linked with the meta title $this->tpl->assign('title', $this->record['title']); // set meta $this->header->setPageTitle($this->record['meta_title'], $this->record['meta_description_overwrite'] == 'Y'); $this->header->addMetaDescription($this->record['meta_description'], $this->record['meta_description_overwrite'] == 'Y'); $this->header->addMetaKeywords($this->record['meta_keywords'], $this->record['meta_keywords_overwrite'] == 'Y'); // advanced SEO-attributes if (isset($this->record['meta_data']['seo_index'])) { $this->header->addMetaData(array('name' => 'robots', 'content' => $this->record['meta_data']['seo_index'])); } if (isset($this->record['meta_data']['seo_follow'])) { $this->header->addMetaData(array('name' => 'robots', 'content' => $this->record['meta_data']['seo_follow'])); } if (!empty($this->record['image'])) { $imgURL = FRONTEND_FILES_URL . '/Media/Images/Source/' . $this->record['image']['filename']; } else { $imgURL = ''; } $this->header->setTwitterCard($this->record['title'] . ' - ' . implode(' - ', $parentCategories), $this->record['meta_description'], $imgURL); // Open Graph-data: add additional OpenGraph data // add specified image if ($imgURL != '') { $this->header->addOpenGraphImage($imgURL); } // Open Graph-data: add images from content $this->header->extractOpenGraphImages($this->record['text']); $this->header->addOpenGraphData('title', $this->record['title'] . ' - ' . implode(' - ', $parentCategories), true); $this->header->addOpenGraphData('type', 'product', true); $this->header->addOpenGraphData('url', SITE_URL . $this->record['full_url'], true); $this->header->addOpenGraphData('site_name', $this->get('fork.settings')->get('Core', 'site_title_' . FRONTEND_LANGUAGE, SITE_DEFAULT_TITLE), true); $this->header->addOpenGraphData('description', $this->record['meta_description_overwrite'] == 'Y' ? $this->record['meta_description'] : $this->record['title'] . ' - ' . implode(' - ', $parentCategories), true); // assign item information $this->tpl->assign('item', $this->record); $this->tpl->assign('brand', $this->brand); if (!empty($this->relatedProducts)) { $this->tpl->assign('related', $this->relatedProducts); } $this->tpl->assign('images', $this->record['images']); if ($this->videos != null) { $this->tpl->assign('videos', $this->videos); } if ($this->files != null) { $this->tpl->assign('files', $this->files); } $this->tpl->assign('specifications', $this->specifications); $this->tpl->assign('tags', $this->tags); //$this->tpl->assign('related', $this->relatedProducts); // count comments $commentCount = count($this->comments); if ($commentCount > 1) { $this->tpl->assign('commentsMultiple', true); } // assign the comments $this->tpl->assign('commentsCount', $commentCount); $this->tpl->assign('comments', $this->comments); if ($this->record["contact"] == 1) { $this->tpl->assign('contactAllowed', true); } // parse the form $this->frm->parse($this->tpl); // some options if ($this->URL->getParameter('comment', 'string') == 'moderation') { $this->tpl->assign('commentIsInModeration', true); } if ($this->URL->getParameter('comment', 'string') == 'spam') { $this->tpl->assign('commentIsSpam', true); } if ($this->URL->getParameter('comment', 'string') == 'true') { $this->tpl->assign('commentIsAdded', true); } $this->tpl->assign('categoriesTree', $this->categoriesTree); }