Try this here, I tested it, it most of the times works on my v.1.5.6.4+:
http://perfectcod.es/2013/07/05/opencar ... rough-url/
Ernie
bigmax.ch/shop/
----- Start taken from the Site!
Although the built-in language selection in OpenCart close to perfect, If you need a language switcher extension for any text anywhere on the site, here are simple code to create links that direct users to the store in a specific language.
This code may use http referer as redirect URL, so it’s no redirect URL need.
Open file in
catalog/controller/module/language.php
Add this code before line 4:
Code: Select all
if (isset($this->request->get['lang'])) {
$this->session->data['language'] = $this->request->get['lang'];
if (isset($_SERVER['HTTP_REFERER']) && (strpos($_SERVER['HTTP_REFERER'], $this->config->get('config_url')) !== false) ) {
$this->redirect($_SERVER['HTTP_REFERER']);
} else {
$this->redirect($this->url->link('common/home'));
}
} else
So, that the 'Modded Section will look like this
Finished/Combined Example, starting from Line 1:
Code: Select all
<?php
class ControllerModuleLanguage extends Controller {
protected function index() {
if (isset($this->request->get['lang'])) {
$this->session->data['language'] = $this->request->get['lang'];
if (isset($_SERVER['HTTP_REFERER']) && (strpos($_SERVER['HTTP_REFERER'], $this->config->get('config_url')) !== false) ) {
$this->redirect($_SERVER['HTTP_REFERER']);
} else {
$this->redirect($this->url->link('common/home'));
}
} elseif (isset($this->request->post['language_code'])) {
$this->session->data['language'] = $this->request->post['language_code'];
if (isset($this->request->post['redirect'])) {
$this->redirect($this->request->post['redirect']);
} else {
$this->redirect($this->url->link('common/home'));
}
}
----- END taken from the Site!
BE AWARE, that you have JUST created an
ELSEIF ... out of your
ELSE - end of Mod, like:
from:
} else
to:
} elseif .......
[/b]
----- taken from the Site!
Now you may test your language in URL. If you have English and Spanish on your site and you would use:
http://yourstore.com/?lang=en (for English) or
http://yourstore.com/?lang=es (for Spanish)[/code]
----- END taken from the Site!
http://forum.opencart.com/viewtopic.php?f=24&t=13273
http://forum.opencart.com/viewtopic.php?f=20&t=69231
GOOGLE FOR: "language in URL Opencart"