1. somemody knows, how to modify the language module, that by clicking on icon of another language, the same page will be shown in choosed language and not the homepage?
2. another question: being in .tpl file, which php variable content id from current language?
This has been done by Bruce, there is also a fork of this project that has this feature standard. See http://www.opencart-extras.com/ssCMS.php?page=1.0a
-Dave
-Dave
Professional Website Services - http://www.davidmgilbert.com/
Active Member
as follows
catalog\template\default\module\language.tpl
add the following to be inside the form tag
catalog\extension\module\language.php
finally, change library\application\router.php as follows (some surrounding code shown for positioning)
catalog\template\default\module\language.tpl
add the following to be inside the form tag
Code: Select all
<?php if(isset($pageURL)) { ?>
<input type="hidden" name="redirect" value="<?php echo $pageURL ?>"/>
<?php } ?>
Code: Select all
<?php
/**
* @desc Contribution: Stay at same page when changing language.
* @author bruce
*
* related changes have been made to...
* module/language.tpl
* library/application/router.php
*/
class ModuleLanguage extends Controller
{
function fetch()
{
$config =& $this->locator->get('config');
$database =& $this->locator->get('database');
$language =& $this->locator->get('language');
$request =& $this->locator->get('request');
$response =& $this->locator->get('response');
$session =& $this->locator->get('session');
$url =& $this->locator->get('url');
if ($config->get('language_status'))
{
if (($request->isPost()) && ($request->has('language', 'post')))
{
$language->set($request->get('language', 'post'));
//
// To return the customer to the page they were already on.
//
if ($request->has('redirect', 'post'))
{
$response->redirect($request->get('redirect', 'post'));
}
else
{
//
// Fall back to the original behaviour.
//
$response->redirect($url->href('home'));
}
}
$language->load('extension/module/language.php');
$view = $this->locator->create('template');
//
// Put the current page url in the template data for posting back
// to the section above.
//
if ($session->has('pageURL'))
{
$view->set('pageURL', $session->get('pageURL'));
}
$view->set('heading_title', $language->get('heading_title'));
$view->set('action', $url->href('home'));
$view->set('text_language', $language->get('text_language'));
$view->set('entry_language', $language->get('entry_language'));
$view->set('default', $language->getCode());
$view->set('languages', $database->cache('language', "select * from language order by sort_order"));
return $view->fetch('module/language.tpl');
}
}
}
?>
Code: Select all
function __construct(&$locator)
{
$this->database =& $locator->get('database');
$this->session =& $locator->get('session');
if ((isset($_SERVER['PATH_INFO'])) && ($_SERVER['PATH_INFO']))
{
$path = urldecode($_SERVER['PATH_INFO']);
// save the path of the current page to the session.
$this->session->set('pageURL', $path);
}
else
{
$path = urldecode($_SERVER['REQUEST_URI']);
// save the path of the current page to the session.
$this->session->set('pageURL', $path);
if (strpos($path, '.php') !== FALSE)
Thank you Bruce, vary kind of you.
i want to manually put manually some content in sertain .tpl file, depending of language, without editing controllers and language files, directly in .tpl, just something like:
which var is that?
i want to manually put manually some content in sertain .tpl file, depending of language, without editing controllers and language files, directly in .tpl, just something like:
Code: Select all
if ($lang_id == 1) echo "some english content";
else if ($lang_id == 2) echo "some german content";
My pleasure. :-) I think you are looking for something like this to put in your controller.
It gives you the language ID number for the currently selected language.
And finally, if you have not seen it before, I did the same for currency switching here.
Code: Select all
$view->set('lang_id', $language->getId());
And finally, if you have not seen it before, I did the same for currency switching here.
Last edited by bruce on Wed Jun 18, 2008 9:51 am, edited 1 time in total.
Who is online
Users browsing this forum: No registered users and 51 guests