/** * Add news items to the indexer * @param array * @param integer * @param boolean * @return array */ public function getSearchablePages($arrPages, $intRoot = 0, $blnIsSitemap = false) { $arrRoot = array(); if ($intRoot > 0) { $arrRoot = $this->Database->getChildRecords($intRoot, 'tl_page'); } $time = time(); $arrProcessed = array(); // Get all news archives $objCategory = \KitchenwareCategoryModel::findByProtected(''); // Walk through each archive if ($objCategory !== null) { while ($objCategory->next()) { // Skip news archives without target page if (!$objCategory->jumpTo) { continue; } // Skip news archives outside the root nodes if (!empty($arrRoot) && !in_array($objCategory->jumpTo, $arrRoot)) { continue; } // Get the URL of the jumpTo page if (!isset($arrProcessed[$objCategory->jumpTo])) { $objParent = \PageModel::findWithDetails($objCategory->jumpTo); // The target page does not exist if ($objParent === null) { continue; } // The target page has not been published (see #5520) if (!$objParent->published || $objParent->start != '' && $objParent->start > $time || $objParent->stop != '' && $objParent->stop < $time) { continue; } // The target page is exempt from the sitemap (see #6418) if ($blnIsSitemap && $objParent->sitemap == 'map_never') { continue; } // Set the domain (see #6421) $domain = ($objParent->rootUseSSL ? 'https://' : 'http://') . ($objParent->domain ?: \Environment::get('host')) . TL_PATH . '/'; // Generate the URL $arrProcessed[$objCategory->jumpTo] = $domain . $this->generateFrontendUrl($objParent->row(), \Config::get('useAutoItem') && !\Config::get('disableAlias') ? '/%s' : '/items/%s', $objParent->language); } $strUrl = $arrProcessed[$objCategory->jumpTo]; // Get the items $objProduct = \KitchenwareProductModel::findPublishedByPid($objCategory->id); if ($objProduct !== null) { while ($objProduct->next()) { $arrPages[] = $this->getLink($objProduct, $strUrl); } } } } return $arrPages; }
/** * Generate the module */ protected function compile() { global $objPage; $this->Template->product = ''; $this->Template->referer = 'javascript:history.go(-1)'; $this->Template->back = $GLOBALS['TL_LANG']['MSC']['goBack']; $this->Template->txt_types = $GLOBALS['TL_LANG']['MSC']['txt_types']; $this->Template->txt_pieces = $GLOBALS['TL_LANG']['MSC']['txt_pieces']; $this->Template->txt_relateds = $GLOBALS['TL_LANG']['MSC']['txt_relateds']; // Generate products $objKitchenwareProduct = \KitchenwareProductModel::findPublishedByParentAndIdOrAlias(\Input::get('items'), $this->kitchenware_categories); $arrKitchenwareProduct = $this->parseProduct($objKitchenwareProduct); $objPage->pageTitle = strip_tags(strip_insert_tags($objKitchenwareProduct->title)); $objPage->description = strip_tags(strip_insert_tags($objKitchenwareProduct->meta_description)); $this->Template->product = $arrKitchenwareProduct; // Generate pieces if ($this->kitchenware_piece_show) { $objKitchenwarePieces = \KitchenwarePieceModel::findPublishedByPid($objKitchenwareProduct->id); if ($objKitchenwarePieces !== null) { $this->Template->pieces = $this->parsePieces($objKitchenwarePieces); } } // Generate types if ($this->kitchenware_type_show) { $objKitchenwareTypes = \KitchenwareTypeModel::findPublishedByPid($objKitchenwareProduct->id); if ($objKitchenwareTypes !== null) { $this->Template->types = $this->parseTypes($objKitchenwareTypes); } } // Generate relateds if ($this->kitchenware_related_show and $objKitchenwareProduct->related) { $this->relateds = deserialize($objKitchenwareProduct->related); $objKitchenwareRelateds = \KitchenwareProductModel::findPublishedByIds($this->relateds); if ($objKitchenwareRelateds !== null) { $this->Template->relateds = $this->parseRelateds($objKitchenwareRelateds); } } }
/** * Generate the module */ protected function compile() { $offset = intval($this->skipFirst); $limit = null; // Maximum number of items if ($this->numberOfItems > 0) { $limit = $this->numberOfItems; } // Handle featured news if ($this->kitchenware_featured == 'featured') { $blnFeatured = true; } elseif ($this->kitchenware_featured == 'unfeatured') { $blnFeatured = false; } else { $blnFeatured = null; } $intTotal = \KitchenwareProductModel::countPublishedByPids($this->kitchenware_categories); if ($intTotal < 1) { return; } $total = $intTotal - $offset; // Split the results if ($this->perPage > 0 && (!isset($limit) || $this->numberOfItems > $this->perPage)) { // Adjust the overall limit if (isset($limit)) { $total = min($limit, $total); } // Get the current page $id = 'page_n' . $this->id; $page = \Input::get($id) ?: 1; // Do not index or cache the page if the page number is outside the range if ($page < 1 || $page > max(ceil($total / $this->perPage), 1)) { global $objPage; $objPage->noSearch = 1; $objPage->cache = 0; // Send a 404 header header('HTTP/1.1 404 Not Found'); return; } // Set limit and offset $limit = $this->perPage; $offset += (max($page, 1) - 1) * $this->perPage; $skip = intval($this->skipFirst); // Overall limit if ($offset + $limit > $total + $skip) { $limit = $total + $skip - $offset; } // Add the pagination menu $objPagination = new \Pagination($total, $this->perPage, \Config::get('maxPaginationLinks'), $id); $this->Template->pagination = $objPagination->generate("\n "); } // Get the items if (isset($limit)) { $objProducts = \KitchenwareProductModel::findPublishedByPids($this->kitchenware_categories, $blnFeatured, $limit, $offset); } else { $objProducts = \KitchenwareProductModel::findPublishedByPids($this->kitchenware_categories, $blnFeatured, 0, $offset); } // Add the Sets if ($objProducts !== null) { $this->Template->products = $this->parseProducts($objProducts); } //$this->Template->gategories = $this->kitchenware_categories; }