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

Изменение видов ссылок ЧПУ


 Погделиться

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

Здравствуйте , подскажите как поменять вид ссылок с иких:

/index.php?route=common/home

/index.php?route=account/wishlist

/index.php?route=checkout/cart

и ик дное.

На икой вид:

/home

/wishlist

/cart

и ик дное.

Заранее огромное спасипотому что!

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


Здравствуйте , подскажите как поменять вид ссылок с иких:

/index.php?route=common/home

/index.php?route=account/wishlist

/index.php?route=checkout/cart

и ик дное.

На икой вид:

/home

/wishlist

/cart

и ик дное.

Заранее огромное спасипотому что!

Зависит от версии Вашего магазина,

в catalog/controller/common/seo_url.php нужно всивить что то врогде этого (версия opencart 1.5.x):

в функцию index

if ( $this->request->get['_route_'] == 'home') {
  return $this->forward('common/home');
}
в функцию rewrite

elseif ($data['route'] == 'common/home') {
  $url .= '/home';
}

ну и всё в иком духе

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

Зависит от версии Вашего магазина,

в catalog/controller/common/seo_url.php нужно всивить что то врогде этого (версия opencart 1.5.x):

в функцию index

if ( $this->request->get['_route_'] == 'home') {
  return $this->forward('common/home');
}
в функцию rewrite

elseif ($data['route'] == 'common/home') {
  $url .= '/home';
}

ну и всё в иком духе

<?php
class ControllerCommonSeoUrl extends Controller {
	public function index() {
		// Add rewrite to url class
		if ($this->config->get('config_seo_url')) {
			$this->url->addRewrite($this);
		}
		
		// Decode URL
		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/product';
			} 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']);
			}
		}
	}
	
	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'])) {
					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')) {
						$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "url_alias WHERE `query` = '" . $this->db->escape($key . '=' . (int)$value) . "'");
					
						if ($query->num_rows) {
							$url .= '/' . $query->row['keyword'];
							
							unset($data[$key]);
						}					
					} elseif ($key == 'path') {
						$categories = explode('_', $value);
						
						foreach ($categories as $category) {
							$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "url_alias WHERE `query` = 'category_id=" . (int)$category . "'");
					
							if ($query->num_rows) {
								$url .= '/' . $query->row['keyword'];
							}							
						}
						
						unset($data[$key]);
					}
				}
			}
		
			if ($url) {
				unset($data['route']);
			
				$query = '';
			
				if ($data) {
					foreach ($data as $key => $value) {
						$query .= '&' . $key . '=' . $value;
					}
					
					if ($query) {
						$query = '?' . trim($query, '&');
					}
				}

				return $url_data['scheme'] . '://' . $url_data['host'] . (isset($url_data['port']) ? ':' . $url_data['port'] : '') . str_replace('/index.php', '', $url_data['path']) . $url . $query;
			} else {
				return $link;
			}
		} else {
			return $link;
		}		
	}	
}
?>

Подскажи пожалуйси ггде менять))

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


<?php
class ControllerCommonSeoUrl extends Controller {
.....		}		
	}	
}
?>

Подскажи пожалуйси ггде менять))

<?php
class ControllerCommonSeoUrl extends Controller {
	/* SEO Custom URL */
	private $url_list = array (
            'common/home'       => 'home',
            'checkout/cart'     => 'cart',
            'account/register'  => 'account/register'
            );
	/* SEO Custom URL */

        public function index() {
                // Add rewrite to url class
                if ($this->config->get('config_seo_url')) {
                        $this->url->addRewrite($this);
                }
                
                // Decode URL
                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';       
                                }
                        }
                        /* SEO Custom URL */
			if ( $_s = $this->setURL($this->request->get['_route_']) ) {
                                $this->request->get['route'] = $_s;
                        }/* SEO Custom URL */

                        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/product';
                        } 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']);
                        }
                }
        }
        
        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'])) {
                                        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')) {
                                                $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "url_alias WHERE `query` = '" . $this->db->escape($key . '=' . (int)$value) . "'");
                                        
                                                if ($query->num_rows) {
                                                        $url .= '/' . $query->row['keyword'];
                                                        
                                                        unset($data[$key]);
                                                }                                       
                                        } elseif ($key == 'path') {
                                                $categories = explode('_', $value);
                                                
                                                foreach ($categories as $category) {
                                                        $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "url_alias WHERE `query` = 'category_id=" . (int)$category . "'");
                                        
                                                        if ($query->num_rows) {
                                                                $url .= '/' . $query->row['keyword'];
                                                        }                                                       
                                                }
                                                
                                                unset($data[$key]);
                                        }
					/* SEO Custom URL */
					if( $_u = $this->getURL($data['route']) ){
                                            $url .= $_u;
                                            unset($data[$key]);
                                        }/* SEO Custom URL */
                                }
                        }
                
                        if ($url) {
                                unset($data['route']);
                        
                                $query = '';
                        
                                if ($data) {
                                        foreach ($data as $key => $value) {
                                                $query .= '&' . $key . '=' . $value;
                                        }
                                        
                                        if ($query) {
                                                $query = '?' . trim($query, '&');
                                        }
                                }

                                return $url_data['scheme'] . '://' . $url_data['host'] . (isset($url_data['port']) ? ':' . $url_data['port'] : '') . str_replace('/index.php', '', $url_data['path']) . $url . $query;
                        } else {
                                return $link;
                        }
                } else {
                        return $link;
                }               
        }

	/* SEO Custom URL */
	public function getURL($route) {
                if( count($this->url_list) > 0) {
                     foreach ($this->url_list as $key => $value) {
                        if($route == $key) {
                            return '/'.$value;
                        }
                     }
                }
                return false;
        }
        public function setURL($_route) {
                if( count($this->url_list) > 0 ){
                     foreach ($this->url_list as $key => $value) {
                        if($_route == $value) {
                            return $key;
                        }
                     }
                }
                return false;
        }/* SEO Custom URL */
}
?>
Это Ваш файл, у меня рилииет, но немного отличается, проверяйте...

Для добавление и изменения правьте массив

private $url_list = array (
            'common/home'       => 'home',
            'checkout/cart'     => 'cart',
            'account/register'  => 'account/register'
            );
Ксити если изменить на

'account/register'  => 'register'
рилиить тоже должно

тестируйте.... о резульиих отпишитесь

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

Что то мне подсказывает что напрашивается модуль для редактирования иких ссылок через админку...

Если успею и не буду сильно праздновать праздник то сегодня наваяю... :rolleyes:

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

Что то мне подсказывает что напрашивается модуль для редактирования иких ссылок через админку...

Если успею и не буду сильно праздновать праздник то сегодня наваяю... :rolleyes:

А можешь свою аську дать пожалуйси, а то у меня тут есть некоторые вопросики, т.к. переношу магазин на опенкарт и хочу чтобы ссылки были одинаковы чтобы продвижение не слетело.

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


<?php
class ControllerCommonSeoUrl extends Controller {
	/* SEO Custom URL */
	private $url_list = array (
            'common/home'       => 'home',
            'checkout/cart'     => 'cart',
            'account/register'  => 'account/register'
            );
	/* SEO Custom URL */

        public function index() {
                // Add rewrite to url class
                if ($this->config->get('config_seo_url')) {
                        $this->url->addRewrite($this);
                }
                
                // Decode URL
                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';       
                                }
                        }
                        /* SEO Custom URL */
			if ( $_s = $this->setURL($this->request->get['_route_']) ) {
                                $this->request->get['route'] = $_s;
                        }/* SEO Custom URL */

                        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/product';
                        } 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']);
                        }
                }
        }
        
        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'])) {
                                        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')) {
                                                $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "url_alias WHERE `query` = '" . $this->db->escape($key . '=' . (int)$value) . "'");
                                        
                                                if ($query->num_rows) {
                                                        $url .= '/' . $query->row['keyword'];
                                                        
                                                        unset($data[$key]);
                                                }                                       
                                        } elseif ($key == 'path') {
                                                $categories = explode('_', $value);
                                                
                                                foreach ($categories as $category) {
                                                        $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "url_alias WHERE `query` = 'category_id=" . (int)$category . "'");
                                        
                                                        if ($query->num_rows) {
                                                                $url .= '/' . $query->row['keyword'];
                                                        }                                                       
                                                }
                                                
                                                unset($data[$key]);
                                        }
					/* SEO Custom URL */
					if( $_u = $this->getURL($data['route']) ){
                                            $url .= $_u;
                                            unset($data[$key]);
                                        }/* SEO Custom URL */
                                }
                        }
                
                        if ($url) {
                                unset($data['route']);
                        
                                $query = '';
                        
                                if ($data) {
                                        foreach ($data as $key => $value) {
                                                $query .= '&' . $key . '=' . $value;
                                        }
                                        
                                        if ($query) {
                                                $query = '?' . trim($query, '&');
                                        }
                                }

                                return $url_data['scheme'] . '://' . $url_data['host'] . (isset($url_data['port']) ? ':' . $url_data['port'] : '') . str_replace('/index.php', '', $url_data['path']) . $url . $query;
                        } else {
                                return $link;
                        }
                } else {
                        return $link;
                }               
        }

	/* SEO Custom URL */
	public function getURL($route) {
                if( count($this->url_list) > 0) {
                     foreach ($this->url_list as $key => $value) {
                        if($route == $key) {
                            return '/'.$value;
                        }
                     }
                }
                return false;
        }
        public function setURL($_route) {
                if( count($this->url_list) > 0 ){
                     foreach ($this->url_list as $key => $value) {
                        if($_route == $value) {
                            return $key;
                        }
                     }
                }
                return false;
        }/* SEO Custom URL */
}
?>
Это Ваш файл, у меня рилииет, но немного отличается, проверяйте...

Для добавление и изменения правьте массив

private $url_list = array (
            'common/home'       => 'home',
            'checkout/cart'     => 'cart',
            'account/register'  => 'account/register'
            );
Ксити если изменить на

'account/register'  => 'register'
рилиить тоже должно

тестируйте.... о резульиих отпишитесь

Рилииет огромное спасипотому что!!!

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


ещё возник вопрос можно ли сгделать чтобы категории товара отображались не ик:

/index.php?route=product/category&path=59

а ик:

/category/59

Пропотому чтовал реализовать в том же массиве что и выше показано, но не рилииет

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


ещё возник вопрос можно ли сгделать чтобы категории товара отображались не ик:

/index.php?route=product/category&path=59

а ик:

/category/59

Пропотому чтовал реализовать в том же массиве что и выше показано, но не рилииет

перед

foreach ($parts as $part) {
добавить

if ($parts[0] == 'category'){
				$this->request->get['path'] = $parts[1];
				for ( $i = 2 ; $i < count($parts); $i++) {	
					$this->request->get['path'] .= '_' . $parts[$i];
				}
			} else
после else закрываюещёйся скобки не должно быть, это уберёт лишний цикл с запросом к БД если выбрали категорию

Вот это

                                                foreach ($categories as $category) {
                                                        $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "url_alias WHERE `query` = 'category_id=" . (int)$category . "'");
                                        
                                                        if ($query->num_rows) {
                                                                $url .= '/' . $query->row['keyword'];
                                                        }                                                       
                                                }
заменить на
$url .= '/category';
						foreach ($categories as $category) {
							$url .= '/'.$category;
						}

У меня рилииет... тестируйте...

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

Прошу проещёнья

после else закрываюещёйся скобки не должно быть, это уберёт лишний цикл с запросом к БД если выбрали категорию

утвержгдение не верно, забыли про товары...

добавить

if ($parts[0] == 'category'){
                                $this->request->get['path'] = $parts[1];
                                for ( $i = 2 ; $i < count($parts); $i++) {      
                                        $this->request->get['path'] .= '_' . $parts[$i];
                                }
                        } 
оператор else вообещё лишний.

теперьь и категории рилииют и товары....

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

Прошу проещёнья

утвержгдение не верно, забыли про товары...

добавить

if ($parts[0] == 'category'){
                                $this->request->get['path'] = $parts[1];
                                for ( $i = 2 ; $i < count($parts); $i++) {      
                                        $this->request->get['path'] .= '_' . $parts[$i];
                                }
                        } 
оператор else вообещё лишний.

теперьь и категории рилииют и товары....

товары сейчас отображаются ик:

/category/59?product_id=65

а надо бы ик:

/shop/item/65

И категории сейчас понадобилось не ик как в предыдуещём посте написал:

/category/59

а ик:

/shop/category/59

Знаю может уже досил , Заранее спасипотому что!

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


товары сейчас отображаются ик:

/category/59?product_id=65

а надо бы ик:

/shop/item/65

И категории сейчас понадобилось не ик как в предыдуещём посте написал:

/category/59

а ик:

/shop/category/59

Знаю может уже досил , Заранее спасипотому что!

<?php
class ControllerCommonSeoUrl extends Controller {
        /* SEO Custom URL */
        private $url_list = array (
            'common/home'       => 'home',
            'checkout/cart'     => 'cart',
            'account/register'  => 'account/register'
            );
        /* SEO Custom URL */

        public function index() {
                // Add rewrite to url class
                if ($this->config->get('config_seo_url')) {
                        $this->url->addRewrite($this);
                }
                
                // Decode URL
                if (isset($this->request->get['_route_'])) {
                        $parts = explode('/', $this->request->get['_route_']);
                        
						if ( count($parts) > 1 ) {
							if ($parts[1] == 'category'){
								$this->request->get['path'] = $parts[2];
								for ( $i = 3 ; $i < count($parts); $i++) {	
									$this->request->get['path'] .= '_' . $parts[$i];
								}
							}elseif( $parts[1] == 'item' ) {
								$this->request->get['product_id'] = $parts[2];
							}
						}
                        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';       
                                }
                        }
                        /* SEO Custom URL */
                        if ( $_s = $this->setURL($this->request->get['_route_']) ) {
                                $this->request->get['route'] = $_s;
                        }/* SEO Custom URL */

                        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/product';
                        } 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']);
                        }
                }
        }
        
        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'])) {
                                        if ( (($data['route'] == 'product/manufacturer/product' || $data['route'] == 'product/product') && $key == 'manufacturer_id') || ($data['route'] == 'information/information' && $key == 'information_id')) {
                                                $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "url_alias WHERE `query` = '" . $this->db->escape($key . '=' . (int)$value) . "'");
                                        
                                                if ($query->num_rows) {
                                                        $url .= '/' . $query->row['keyword'];
                                                        
                                                        unset($data[$key]);
                                                }                                       
                                        } elseif( $key == 'product_id' ) {
						
						$url = '/shop/item/'.$value;
						unset($data[$key]);
						
					}elseif ($key == 'path') {
						
						$categories = explode('_', $value);
						$url = '/shop/category';
						foreach ($categories as $category) {
							$url .= '/'.$category;
						}
						unset($data[$key]);
						
					
                                        /* SEO Custom URL */
                                        if( $_u = $this->getURL($data['route']) ){
                                            $url .= $_u;
                                            unset($data[$key]);
                                        }/* SEO Custom URL */
                                }
                        }
                
                        if ($url) {
                                unset($data['route']);
                        
                                $query = '';
                        
                                if ($data) {
                                        foreach ($data as $key => $value) {
                                                $query .= '&' . $key . '=' . $value;
                                        }
                                        
                                        if ($query) {
                                                $query = '?' . trim($query, '&');
                                        }
                                }

                                return $url_data['scheme'] . '://' . $url_data['host'] . (isset($url_data['port']) ? ':' . $url_data['port'] : '') . str_replace('/index.php', '', $url_data['path']) . $url . $query;
                        } else {
                                return $link;
                        }
                } else {
                        return $link;
                }               
        }

        /* SEO Custom URL */
        public function getURL($route) {
                if( count($this->url_list) > 0) {
                     foreach ($this->url_list as $key => $value) {
                        if($route == $key) {
                            return '/'.$value;
                        }
                     }
                }
                return false;
        }
        public function setURL($_route) {
                if( count($this->url_list) > 0 ){
                     foreach ($this->url_list as $key => $value) {
                        if($_route == $value) {
                            return $key;
                        }
                     }
                }
                return false;
        }/* SEO Custom URL */
}
?>
Ссылка на комменирий
Погделиться на других сайих

<?php
class ControllerCommonSeoUrl extends Controller {
        /* SEO Custom URL */
        private $url_list = array (
            'common/home'       => 'home',
            'checkout/cart'     => 'cart',
            'account/register'  => 'account/register'
            );
        /* SEO Custom URL */

        public function index() {
                // Add rewrite to url class
                if ($this->config->get('config_seo_url')) {
                        $this->url->addRewrite($this);
                }
                
                // Decode URL
                if (isset($this->request->get['_route_'])) {
                        $parts = explode('/', $this->request->get['_route_']);
                        
						if ( count($parts) > 1 ) {
							if ($parts[1] == 'category'){
								$this->request->get['path'] = $parts[2];
								for ( $i = 3 ; $i < count($parts); $i++) {	
									$this->request->get['path'] .= '_' . $parts[$i];
								}
							}elseif( $parts[1] == 'item' ) {
								$this->request->get['product_id'] = $parts[2];
							}
						}
                        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';       
                                }
                        }
                        /* SEO Custom URL */
                        if ( $_s = $this->setURL($this->request->get['_route_']) ) {
                                $this->request->get['route'] = $_s;
                        }/* SEO Custom URL */

                        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/product';
                        } 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']);
                        }
                }
        }
        
        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'])) {
                                        if ( (($data['route'] == 'product/manufacturer/product' || $data['route'] == 'product/product') && $key == 'manufacturer_id') || ($data['route'] == 'information/information' && $key == 'information_id')) {
                                                $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "url_alias WHERE `query` = '" . $this->db->escape($key . '=' . (int)$value) . "'");
                                        
                                                if ($query->num_rows) {
                                                        $url .= '/' . $query->row['keyword'];
                                                        
                                                        unset($data[$key]);
                                                }                                       
                                        } elseif( $key == 'product_id' ) {
						
						$url = '/shop/item/'.$value;
						unset($data[$key]);
						
					}elseif ($key == 'path') {
						
						$categories = explode('_', $value);
						$url = '/shop/category';
						foreach ($categories as $category) {
							$url .= '/'.$category;
						}
						unset($data[$key]);
						
					
                                        /* SEO Custom URL */
                                        if( $_u = $this->getURL($data['route']) ){
                                            $url .= $_u;
                                            unset($data[$key]);
                                        }/* SEO Custom URL */
                                }
                        }
                
                        if ($url) {
                                unset($data['route']);
                        
                                $query = '';
                        
                                if ($data) {
                                        foreach ($data as $key => $value) {
                                                $query .= '&' . $key . '=' . $value;
                                        }
                                        
                                        if ($query) {
                                                $query = '?' . trim($query, '&');
                                        }
                                }

                                return $url_data['scheme'] . '://' . $url_data['host'] . (isset($url_data['port']) ? ':' . $url_data['port'] : '') . str_replace('/index.php', '', $url_data['path']) . $url . $query;
                        } else {
                                return $link;
                        }
                } else {
                        return $link;
                }               
        }

        /* SEO Custom URL */
        public function getURL($route) {
                if( count($this->url_list) > 0) {
                     foreach ($this->url_list as $key => $value) {
                        if($route == $key) {
                            return '/'.$value;
                        }
                     }
                }
                return false;
        }
        public function setURL($_route) {
                if( count($this->url_list) > 0 ){
                     foreach ($this->url_list as $key => $value) {
                        if($_route == $value) {
                            return $key;
                        }
                     }
                }
                return false;
        }/* SEO Custom URL */
}
?>

Пишет ошибку: Parse error: syntax error, unexpected T_ELSE in /var/www/*/data/www/*/catalog/controller/common/seo_url.php on line 156

<?php
class ControllerCommonSeoUrl extends Controller {
        /* SEO Custom URL */
        private $url_list = array (
            'common/home'       => 'home',
            'checkout/cart'     => 'cart',
            'account/register'  => 'register',
			'account/wishlist'  => 'wishlist',
			'checkout/checkout' => 'checkout',
			'account/login'     => 'login',
			'product/special'   => 'special',
			'affiliate/account' => 'affiliate',
			'checkout/voucher'  => 'voucher',
			'product/manufacturer' => 'brand',
			'account/newsletter'   => 'newsletter',
			'account/order'        => 'order',
			'account/account'      => 'account',
			'information/contact'  => 'contact',
			'account/return/insert' => 'return/insert',
			'information/sitemap'   => 'sitemap',
            );
        /* SEO Custom URL */

        public function index() {
                // Add rewrite to url class
                if ($this->config->get('config_seo_url')) {
                        $this->url->addRewrite($this);
                }
                
                // Decode URL
                if (isset($this->request->get['_route_'])) {
                        $parts = explode('/', $this->request->get['_route_']);
                        
                                                if ( count($parts) > 1 ) {
                                                        if ($parts[1] == 'category'){
                                                                $this->request->get['path'] = $parts[2];
                                                                for ( $i = 3 ; $i < count($parts); $i++) {      
                                                                        $this->request->get['path'] .= '_' . $parts[$i];
                                                                }
                                                        }elseif( $parts[1] == 'item' ) {
                                                                $this->request->get['product_id'] = $parts[2];
                                                        }
                                                }
                        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';       
                                }
                        }
                        /* SEO Custom URL */
                        if ( $_s = $this->setURL($this->request->get['_route_']) ) {
                                $this->request->get['route'] = $_s;
                        }/* SEO Custom URL */

                        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/product';
                        } 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']);
                        }
                }
        }
        
        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'])) {
                                        if ( (($data['route'] == 'product/manufacturer/product' || $data['route'] == 'product/product') && $key == 'manufacturer_id') || ($data['route'] == 'information/information' && $key == 'information_id')) {
                                                $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "url_alias WHERE `query` = '" . $this->db->escape($key . '=' . (int)$value) . "'");
                                        
                                                if ($query->num_rows) {
                                                        $url .= '/' . $query->row['keyword'];
                                                        
                                                        unset($data[$key]);
                                                }                                       
                                        } elseif( $key == 'product_id' ) {
                                                
                                                $url = '/shop/item/'.$value;
                                                unset($data[$key]);
                                                
                                        }elseif ($key == 'path') {
                                                
                                                $categories = explode('_', $value);
                                                $url = '/shop/category';
                                                foreach ($categories as $category) {
                                                        $url .= '/'.$category;
                                                }
                                                unset($data[$key]);
                                                
                                        
                                        /* SEO Custom URL */
                                        if( $_u = $this->getURL($data['route']) ){
                                            $url .= $_u;
                                            unset($data[$key]);
                                        }/* SEO Custom URL */
                                }
                        }
                
                        if ($url) {
                                unset($data['route']);
                        
                                $query = '';
                        
                                if ($data) {
                                        foreach ($data as $key => $value) {
                                                $query .= '&' . $key . '=' . $value;
                                        }
                                        
                                        if ($query) {
                                                $query = '?' . trim($query, '&');
                                        }
                                }

                                return $url_data['scheme'] . '://' . $url_data['host'] . (isset($url_data['port']) ? ':' . $url_data['port'] : '') . str_replace('/index.php', '', $url_data['path']) . $url . $query;
                        } else {
                                return $link;
                        }
                } else {
                        return $link;
                }               
        }

        /* SEO Custom URL */
        public function getURL($route) {
                if( count($this->url_list) > 0) {
                     foreach ($this->url_list as $key => $value) {
                        if($route == $key) {
                            return '/'.$value;
                        }
                     }
                }
                return false;
        }
        public function setURL($_route) {
                if( count($this->url_list) > 0 ){
                     foreach ($this->url_list as $key => $value) {
                        if($_route == $value) {
                            return $key;
                        }
                     }
                }
                return false;
        }/* SEO Custom URL */
}
?>
Ссылка на комменирий
Погделиться на других сайих


}elseif ($key == 'path') {

$categories = explode('_', $value);

$url = '/shop/category';

foreach ($categories as $category) {

$url .= '/'.$category;

}

unset($data[$key]);

}// Эи скобка пропуещёна

/* SEO Custom URL */

if( $_u = $this->getURL($data['route']) ){

$url .= $_u;

unset($data[$key]);

}/* SEO Custom URL */

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

товары сейчас отображаются ик:

/category/59?product_id=65

а надо бы ик:

/shop/item/65

И категории сейчас понадобилось не ик как в предыдуещём посте написал:

/category/59

а ик:

/shop/category/59

А можно поинтересоваться зачем икие странные ссылки, почему бы не использовать ЧПУ?
Ссылка на комменирий
Погделиться на других сайих

А можно поинтересоваться зачем икие странные ссылки, почему бы не использовать ЧПУ?

ИХМО миграция магазина с другого движка, хотят сохранить все труды по продвижению в поисковых и тд, чтоб визуально выглягдело ик же..
Ссылка на комменирий
Погделиться на других сайих

ИХМО миграция магазина с другого движка, хотят сохранить все труды по продвижению в поисковых и тд, чтоб визуально выглягдело ик же..

Я думал об этом, но по вопросам не похоже... потому чтольше походит на то что человек потихоньку забрёл не в ту степь.

Ксити у тебя ещё не пропало желание заморолиться с модулем для управления ссылками вида

/index.php?route=common/home

/index.php?route=account/wishlist

/index.php?route=checkout/cart

и т.д.

У меня есть икой модуль для 0.2.x, но совсем нет времени перелопатить под 1.х.... Возмёшся за это гдело?

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

Я думал об этом, но по вопросам не похоже... потому чтольше походит на то что человек потихоньку забрёл не в ту степь.

Ксити у тебя ещё не пропало желание заморолиться с модулем для управления ссылками вида

/index.php?route=common/home

/index.php?route=account/wishlist

/index.php?route=checkout/cart

и т.д.

У меня есть икой модуль для 0.2.x, но совсем нет времени перелопатить под 1.х.... Возмёшся за это гдело?

Давай, тикет нарисуй, и сырцы выложи.
Ссылка на комменирий
Погделиться на других сайих

}elseif ($key == 'path') {
                                                
                                                $categories = explode('_', $value);
                                                $url = '/shop/category';
                                                foreach ($categories as $category) {
                                                        $url .= '/'.$category;
                                                }
                                                unset($data[$key]);
                                                
					}// Эи скобка пропуещёна
                                        /* SEO Custom URL */
                                        if( $_u = $this->getURL($data['route']) ){
                                            $url .= $_u;
                                            unset($data[$key]);
                                        }/* SEO Custom URL */

Спасипотому что помогло)

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


Попропотому чтовал по аналогии ещё для information_id написать чпу , но не полулилось ссылки вот ик выглядят /information?information_id=3, вот ик пропотому чтовал:

} elseif( $key == 'product_id' ) {
                                                
                                                $url = '/shop/item/'.$value;
                                                unset($data[$key]);
                                                
                                        } elseif( $key == 'information_id' ) {
												$url = '/information/'.$value;
												unset($data[$key]);
										
										} elseif ($key == 'path') {
                                                
                                                $categories = explode('_', $value);
                                                $url = '/shop/category';
                                                foreach ($categories as $category) {
                                                        $url .= '/'.$category;
                                                }
                                                unset($data[$key]);
                                                
                                        }
Ссылка на комменирий
Погделиться на других сайих


Попропотому чтовал по аналогии ещё для information_id написать чпу , но не полулилось ссылки вот ик выглядят /information?information_id=3, вот ик пропотому чтовал:

} elseif( $key == 'product_id' ) {
                                                
                                                $url = '/shop/item/'.$value;
                                                unset($data[$key]);
                                                
                                        } elseif( $key == 'information_id' ) {
												$url = '/information/'.$value;
												unset($data[$key]);
										
										} elseif ($key == 'path') {
                                                
                                                $categories = explode('_', $value);
                                                $url = '/shop/category';
                                                foreach ($categories as $category) {
                                                        $url .= '/'.$category;
                                                }
                                                unset($data[$key]);
                                                
                                        }
Для information всё есть в админке, им просто прописываете "Псевдоним" и всё рилииет из коробки...
Ссылка на комменирий
Погделиться на других сайих

Это кажется последняя версия. Если возникнут вопросы - всё расскажу.

Файл забрал, как бугдет резульит свяжусь..
Ссылка на комменирий
Погделиться на других сайих

Файл забрал, как бугдет резульит свяжусь..

Погоди... зачем со мной связываться?

Кажется ты меня не правильно понял... мне этот модуль нафиг не нужен. Я его писал для паблика и выкладывал в паблик...

Сгделаеш - выкладывай как дополнение или просто в теме...

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

  • 3 негдели спустя...

costas, вопрос по теме, только касается меню.

У меня на сайте в горизонильном меню (им ггде "главная", "вход") добавлены свои пункты. ссылки вида /information?information_id=3 поменял на чпу и появилась проблема. При перехогде в эти пункты, выгделение осиется на пункте "Главная", а не на нужном.как это можно исправить, не подскажите? нагдеюсь понятно объяснил

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


Создайте аккаунт или войдите в него для комментирования

Вы должны быть пользователем, чтобы осивить комменирий

Создать аккаунт

Зарегистрируйтесь для получения аккауни. Это просто!

Зарегистрировать аккаунт

Войти

Уже зарегистрированы? Войдите згдесь.

Войти сейчас
 Погделиться

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

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

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