Перейти к публикации
  • разработка интернет магазинов на opencart
  • доработка интернет магазинов на opencart

[Решено] Помогите с ЧПУ для модуля новостей (OC 1.4.9)


 Погделиться

Рекомендованные сообещёния

Помогите настроить ЧПУ для модуля новостей в Opencart 1.4.9

Использую модуль

deadcow SEO

Везгде SEO url рилиию, в модуле новостей нет.

Вот пример рилииющих ссылок http://glostore.com....%BC%D0%BA%D0%B8

Вот пример, ггде не рилииет http://glostore.com..../news&news_id=1

Вот файл catalog/controller/common/seo_url.php

<?php
class ControllerCommonSeoUrl extends Controller {
public function index() {
  if (isset($this->request->get['_route_'])) {
   $parts = explode('/', $this->request->get['_route_']);
  
   foreach ($parts as $part) {
	$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "url_alias WHERE keyword = '" . $this->db->escape($part) . "'");
  
	if ($query->num_rows) {
	 $url = explode('=', $query->row['query']);
	
	 if ($url[0] == 'product_id') {
	  $this->request->get['product_id'] = $url[1];
	 }
	
	 if ($url[0] == 'category_id') {
	  if (!isset($this->request->get['path'])) {
	   $this->request->get['path'] = $url[1];
	  } else {
	   $this->request->get['path'] .= '_' . $url[1];
	  }
	 }
	
	 if ($url[0] == 'manufacturer_id') {
	  $this->request->get['manufacturer_id'] = $url[1];
	 }
	
	 if ($url[0] == 'information_id') {
	  $this->request->get['information_id'] = $url[1];
	 }
	} else {
	 $this->request->get['route'] = 'error/not_found';
	}
   }
  
   if (isset($this->request->get['product_id'])) {
	$this->request->get['route'] = 'product/product';
   } elseif (isset($this->request->get['path'])) {
	$this->request->get['route'] = 'product/category';
   } elseif (isset($this->request->get['manufacturer_id'])) {
	$this->request->get['route'] = 'product/manufacturer';
   } elseif (isset($this->request->get['information_id'])) {
	$this->request->get['route'] = 'information/information';
   }
  
   if (isset($this->request->get['route'])) {
	return $this->forward($this->request->get['route']);
   }
  }
}
}
?>
Вот файл admin/controller/module/deadcow_seo.php

<?php
class ControllerModuleDeadcowSEO extends Controller {
	private $error = array();
	public function install() {
		// enable the module and set default settings
		$this->load->model('setting/setting');
		$this->model_setting_setting->editSetting('deadcow_seo', array('deadcow_seo_status' => 1,
																	  'deadcow_seo_categories_template' => '[category_name]',
																	  'deadcow_seo_products_template' => '[product_name]-[model_name]',
																	  'deadcow_seo_manufacturers_template' => '[manufacturer_name]',
																	  'deadcow_seo_meta_template' => '[product_name], [model_name], [manufacturer_name], [categories_names]',
																	  'deadcow_seo_yahoo_id' => '',
																	  'deadcow_seo_yahoo_checkbox' => 0
																 ));
	}
	public function index() {
		$this->load->language('module/deadcow_seo');
		$this->document->title = $this->language->get('heading_title');
		$this->load->model('setting/setting');
		$this->load->model('module/deadcow_seo');
		if (($this->request->server['REQUEST_METHOD'] == 'POST') && ($this->validate())) {
			if (isset($this->request->post['categories'])) {
				$this->model_module_deadcow_seo->generateCategories($this->request->post['categories_template']);
			}
			if (isset($this->request->post['products'])) {
				$this->model_module_deadcow_seo->generateProducts($this->request->post['products_template']);
			}
			if (isset($this->request->post['manufacturers'])) {
				$this->model_module_deadcow_seo->generateManufacturers($this->request->post['manufacturers_template']);
			}
			if (isset($this->request->post['meta_keywords'])) {
				if (!isset($this->request->post['yahoo_checkbox'])) {
					$this->model_module_deadcow_seo->generateMetaKeywords($this->request->post['meta_template']);
				} else if (trim($this->request->post['yahoo_id']) != '') {
					$this->model_module_deadcow_seo->generateMetaKeywords($this->request->post['meta_template'], trim($this->request->post['yahoo_id']));
				} else {
					$this->error['warning'] = $this->language->get('enter_yahoo_id');
				}
			}
			$this->model_setting_setting->editSetting('deadcow_seo', array('deadcow_seo_categories_template' => $this->request->post['categories_template'],
																		  'deadcow_seo_products_template' => $this->request->post['products_template'],
																		  'deadcow_seo_manufacturers_template' => $this->request->post['manufacturers_template'],
																		  'deadcow_seo_meta_template' => $this->request->post['meta_template'],
																		  'deadcow_seo_yahoo_id' => $this->request->post['yahoo_id'],
																		  'deadcow_seo_yahoo_checkbox' => isset($this->request->post['yahoo_checkbox']) ? 1 : 0
																	 ));
			if (isset($this->error['warning'])) {
				$this->data['error_warning'] = $this->error['warning'];
			} else {
				$this->data['success'] = $this->language->get('text_success');
			}
		}
		$this->data['warning_clear'] = $this->language->get('warning_clear');
		$this->data['back'] = $this->language->get('back');
		$this->data['categories'] = $this->language->get('categories');
		$this->data['products'] = $this->language->get('products');
		$this->data['manufacturers'] = $this->language->get('manufacturers');
		$this->data['meta_keywords'] = $this->language->get('meta_keywords');
		$this->data['generate'] = $this->language->get('generate');
		$this->data['append_model'] = $this->language->get('append_model');
		$this->data['template'] = $this->language->get('template');
		$this->data['available_category_tags'] = $this->language->get('available_category_tags');
		$this->data['available_product_tags'] = $this->language->get('available_product_tags');
		$this->data['available_manufacturer_tags'] = $this->language->get('available_manufacturer_tags');
		$this->data['available_meta_tags'] = $this->language->get('available_meta_tags');
		$this->data['your_yahoo_id'] = $this->language->get('your_yahoo_id');
		$this->data['get_yahoo_id'] = $this->language->get('get_yahoo_id');
		$this->data['add_from_yahoo'] = $this->language->get('add_from_yahoo');
		$this->data['curl_not_enabled'] = $this->language->get('curl_not_enabled');
		if (isset($this->request->post['categories_template'])) {
			$this->data['categories_template'] = $this->request->post['categories_template'];
		} else {
			$this->data['categories_template'] = $this->config->get('deadcow_seo_categories_template');
		}
		if (isset($this->request->post['products_template'])) {
			$this->data['products_template'] = $this->request->post['products_template'];
		} else {
			$this->data['products_template'] = $this->config->get('deadcow_seo_products_template');
		}
		if (isset($this->request->post['manufacturers_template'])) {
			$this->data['manufacturers_template'] = $this->request->post['manufacturers_template'];
		} else {
			$this->data['manufacturers_template'] = $this->config->get('deadcow_seo_manufacturers_template');
		}
		if (isset($this->request->post['meta_template'])) {
			$this->data['meta_template'] = $this->request->post['meta_template'];
		} else {
			$this->data['meta_template'] = $this->config->get('deadcow_seo_meta_template');
		}
		if (isset($this->request->post['yahoo_id'])) {
			$this->data['yahoo_id'] = $this->request->post['yahoo_id'];
		} else {
			$this->data['yahoo_id'] = $this->config->get('deadcow_seo_yahoo_id');
		}
		$this->data['yahoo_checkbox'] = isset($this->request->post['yahoo_checkbox']) ? 1 : 0;
		$this->document->breadcrumbs = array();
		$this->document->breadcrumbs[] = array('href' => HTTPS_SERVER . 'index.php?route=common/home&token=' . $this->session->data['token'], 'text' => $this->language->get('text_home'), 'separator' => FALSE);
		$this->document->breadcrumbs[] = array('href' => HTTPS_SERVER . 'index.php?route=extension/module&token=' . $this->session->data['token'], 'text' => $this->language->get('text_module'), 'separator' => ' :: ');
		$this->document->breadcrumbs[] = array('href' => HTTPS_SERVER . 'index.php?route=module/deadcow_seo&token=' . $this->session->data['token'], 'text' => $this->language->get('heading_title'), 'separator' => ' :: ');
		$this->data['action'] = HTTPS_SERVER . 'index.php?route=module/deadcow_seo&token=' . $this->session->data['token'];
		$this->data['cancel'] = HTTPS_SERVER . 'index.php?route=extension/module&token=' . $this->session->data['token'];
		$this->data['heading_title'] = $this->language->get('heading_title');
		$this->template = 'module/deadcow_seo.tpl';
		$this->children = array('common/header', 'common/footer');
		$this->response->setOutput($this->render(TRUE), $this->config->get('config_compression'));
	}
	private function validate() {
		if (!$this->user->hasPermission('modify', 'module/deadcow_seo')) {
			$this->error['warning'] = $this->language->get('error_permission');
		}
		if (!$this->error) {
			return true;
		} else {
			return false;
		}
	}
}
Я ик думаю, надо что-то прописать в последнем файле.

Что-то добавить типа

news_id

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

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

}

И ещё что-то. Буду рад за помощь. Решение нашел только для opencart 1.5 http://opencartforum...-opencart-v151/

Думаю, код можно оттуда, но как всивить сюда не знаю.

Ссылка на комменирий
Погделиться на других сайих


Нашел решение. Всё рилииет.

Вот инструкция.

SEO URLs
To add support for SEO URLs, use the following instructions:–
In "catalog/controller/common/seo_url.php", add the following:–
if ($url[0] == 'news_id') {
	    $this->request->get['news_id'] = $url[1];
}
after
if ($url[0] == 'information_id') {
	    $this->request->get['information_id'] = $url[1];
}
Then insert
} elseif (isset($this->request->get['news_id'])) {
	    $this->request->get['route'] = 'information/news';
before the closing "}" in the block that reads
if (isset($this->request->get['product_id'])) {
	    $this->request->get['route'] = 'product/product';
} elseif (isset($this->request->get['path'])) {
	    $this->request->get['route'] = 'product/category';
} elseif (isset($this->request->get['manufacturer_id'])) {
	    $this->request->get['route'] = 'product/manufacturer';
} elseif (isset($this->request->get['information_id'])) {
	    $this->request->get['route'] = 'information/information';
}
Then in "catalog/model/tool/seo_url.php", insert " || ($key == 'news_id')" into line 14 so that it reads something like:
if (($key == 'product_id') || ($key == 'manufacturer_id') || ($key == 'information_id') || ($key == 'news_id')) {

Единственный вопрос осился, как именно для версии 0.1.7 (1.4.9) сгделать SEO URL для ссылки все новости: /index.php?route=information/news

Ссылка на комменирий
Погделиться на других сайих


Гость
Эи тема закрыи для дальнейших сообещёний.
 Погделиться

×
×
  • Создать...

Важная информация

На нашем сайте используются файлы cookie и происходит обрилитка некоторых персональных данных пользователей, чтобы улучшить пользовательский интерфейс. Чтобы узнать для чего и какие персональные данные мы обрабатываем перейдите по ссылке. Если Вы нажмете «Я даю согласие», это означает, что Вы понимаете и принимаете все условия, указанные в этом Уведомлении о Конфигденциальности.