Кейс: Выводить Новинки на отдельной странице (https://мойСайт/new)
Решение:
1) Создаем страницу "Новинки" с url=new
2) В файле /view/ProductsView.php правим
2.1) 52 строка
Код: Выделить всё
if (in_array($this->page->url, array('all-products', 'discounted', 'bestsellers'))
меняем на
Код: Выделить всё
if (in_array($this->page->url, array('all-products', 'discounted', 'bestsellers', 'new'))
2.2) ищем объявление функции filter_chpu_parse_url() (307 строка)
2.2.1)находим
Код: Выделить всё
preg_match("~^$this->subdir(/?$this->lang_label)?/?(catalog|all-products|brands|discounted|bestsellers)/?~", $uri['path'], $this->catalog_type);
меняем на
Код: Выделить всё
preg_match("~^$this->subdir(/?$this->lang_label)?/?(catalog|all-products|brands|discounted|bestsellers|new)/?~", $uri['path'], $this->catalog_type);
2.2.2) находим
Код: Выделить всё
$uri = preg_replace("~^$this->subdir(/?$this->lang_label)?/?(catalog|all-products|brands|discounted|bestsellers)/?~",'',$uri['path']);
меняем на
Код: Выделить всё
$uri = preg_replace("~^$this->subdir(/?$this->lang_label)?/?(catalog|all-products|brands|discounted|bestsellers|new)/?~",'',$uri['path']);
2.3) ищем $mode = $this->request->get('mode'); (370 строка)
правим условия
Код: Выделить всё
if (!empty($mode)) {
if ($mode == 'bestsellers') {
$filter['featured'] = 1;
} elseif ($mode == 'discounted') {
$filter['discounted'] = 1;
}
}
на
Код: Выделить всё
if (!empty($mode)) {
if ($mode == 'bestsellers') {
$filter['featured'] = 1;
} elseif ($mode == 'discounted') {
$filter['discounted'] = 1;
} elseif ($mode == 'new') {
$filter['sort'] = 'created';
}
}
3) В файле /view/View.php в строке 136
Код: Выделить всё
if (in_array($_GET['page_url'], array('all-products', 'discounted', 'bestsellers'))) {
заменяем на
Код: Выделить всё
if (in_array($_GET['page_url'], array('all-products', 'discounted', 'bestsellers', 'new'))) {
4) В файле /.htaccess добавляем правило
Код: Выделить всё
RewriteRule ^([a-z]{2}/)?new/?$ index.php?module=ProductsView&lang_label=$1&mode=new [L,QSA]
RewriteRule ^([a-z]{2}/)?new/([^/]+) index.php?module=ProductsView&lang_label=$1&page_url=new&mode=new [L,QSA]