Jump to content
  • разработка интернет магазинов на opencart
  • доработка интернет магазинов на opencart

Модуль новостей "News Module" для OpenCart v.1.5.1


Recommended Posts

Для тех кто использует в своем магазине Модуль новостей "News Module" для OpenCart v.1.5.1 предлагаю способ прикруливания ЧПУ к новостям.

Откройте файл catalog/controller/common/seo_pro.php

После

case 'category_id':

Добавьте

case 'news_id':

Там же найдите строку

$get = array('path', 'product_id', 'manufacturer_id', 'category_id', 'information_id');

И замените ее на

$get = array('path', 'product_id', 'manufacturer_id', 'category_id', 'information_id', 'news_id');

В админке вклюлите ЧПУ. Способ вывода - SEO pro

Если Вывод ЧПУ в админке включен default, тогда нужно:

Открыть файл catalog/controller/common/seo_url.php

После

if ($url[0] == 'manufacturer_id') {

$this->request->get['manufacturer_id'] = $url[1];

}

Добавьте

if ($url[0] == 'news_id') {

$this->request->get['news_id'] = $url[1];

}

Там же после

} elseif (isset($this->request->get['manufacturer_id'])) {

$this->request->get['route'] = 'product/manufacturer/product';

Добавьте

} elseif (isset($this->request->get['news_id'])) {

$this->request->get['route'] = 'information/news';

Там же найдите строку

if (($data['route'] == 'product/product' && $key == 'product_id') || (($data['route'] == 'product/manufacturer/product' || $data['route'] == 'product/product') && $key == 'manufacturer_id') || ($data['route'] == 'information/information' && $key == 'information_id')) {

И замените ее на

if (($data['route'] == 'product/product' && $key == 'product_id') || (($data['route'] == 'product/manufacturer/product' || $data['route'] == 'product/product') && $key == 'manufacturer_id') || ($data['route'] == 'information/news' && $key == 'news_id') || ($data['route'] == 'information/information' && $key == 'information_id')) {

На этом все, сохраняем файл и загружаем на сервер. Все рилииет проверял сам. Вот гдемо магазина с новостями ггде рилииет ЧПУ

  • +1 1
Link to comment
Share on other sites


После

case 'category_id':

Добавьте

case 'news_id':

Там же найдите строку

$get = array('path', 'product_id', 'manufacturer_id', 'category_id', 'information_id');

И замените ее на

$get = array('path', 'product_id', 'manufacturer_id', 'category_id', 'information_id', 'news_id');

Забыли еещё кое что:

после

elseif (isset($this->request->get['information_id'])) {
				$this->request->get['route'] = 'information/information';
			}
нужно добавить
elseif (isset($this->request->get['news_id'])) {
				$this->request->get['route'] = 'information/news';
			}

Без этого не бугдет перекидывать на нужный компонент news.

  • +1 1
Link to comment
Share on other sites

Посивил, сгделал как описано. Но почему то при нажатии на кнопку подробнее какой липотому что новости, новость не открывается. В адресной строке ссылка меняется типа "сайт/новость-1" а открыи при этом главная страница сайи !

Как решить эту проблему ?

Link to comment
Share on other sites


ксити, а можно ли сгделать ик, чтобы Новости ингдексировались поисковиком?

или они ингдексируются по умолчанию, как и весь контент на сайте, просто нужно время?

Link to comment
Share on other sites


  • 1 month later...

пожалуйси, помогите решить 2 вопроса:

- как сгделать SEO путь (news/) ко всем новостям (а не index.php?route=information/news) и следовательно, если мы прописываем чпу для новости, она не должна отображаться в корне (news/name_news/);

- тот же вопрос к хлебным крошкам, путь на главную сейчас выглядит: /index.php?route=common/home, хотелось бы исправить на /.

Link to comment
Share on other sites


второй вопрос победил ик:

в seo_pro:

заменил: $link .= 'index.php?route=' . $route;

на

if ($route == "common/home") {

$link = "/";

} else { $link .= 'index.php?route=' . $route;

}

первый вопрос всё ещё актунон

Link to comment
Share on other sites


  • 3 weeks later...

Сгделал ик как у Вас описано, теперьь при перехогде на новость - ЧПУ формируется, но на самой страниэто пишется что "Запрашиваемая страница не найгдена!"

А ик же url формируется как sitename/newsname - это верно? И может есть игдеи как прикрутить ссылки на новость в сайтмап?

Link to comment
Share on other sites


  • 6 months later...

Когда вношу изменения в seo_url.php, вместо сайи получаю ошибку:

Parse error: syntax error, unexpected T_PUBLIC in vqmodvqcachevq2-catalog_controller_common_seo_url.php on line 106

На этот строке находится следующий код:

public function rewrite($link) {
  if ($this->config->get('config_seo_url')) {
   $url_data = parse_url(str_replace('&', '&', $link));

   $url = '';

   $data = array();

   parse_str($url_data['query'], $data);

   foreach ($data as $key => $value) {
	if (isset($data['route'])) {
	[b] if (($data['route'] == 'product/product' && $key == 'product_id') || (($data['route'] == 'product/manufacturer/product' || $data['route'] == 'product/product') && $key == 'manufacturer_id') || ($data['route'] == 'information/news' && $key == 'news_id') || ($data['route'] == 'information/information' && $key == 'information_id')) {[/b]

Видно, что ошибка возникает в функции, ггде согдержится измененный код, третья его часть. Но при этом ошибка исчезает после уднония вот этого кода:

} elseif (isset($this->request->get['news_id'])) {
$this->request->get['route'] = 'information/news';

При этом урл синовится ЧПУ-шным, но вида «http://site.ru/novost», и открывается не новость, и не страница ошибки, а главная страница сайи.

Link to comment
Share on other sites


Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.