Post by dr770 » Tue Jun 17, 2008 5:23 pm

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?

New member

Posts

Joined
Mon Oct 15, 2007 1:53 am

Post by david.gilbert » Tue Jun 17, 2008 7:02 pm

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

Professional Website Services - http://www.davidmgilbert.com/


Active Member

Posts

Joined
Sun Jan 06, 2008 5:02 pm
Location - Mount Compass, South Australia

Post by bruce » Wed Jun 18, 2008 7:36 am

as follows

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 } ?>
catalog\extension\module\language.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'); 
		}
	}
}
?>
finally, change library\application\router.php as follows (some surrounding code shown for positioning)

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) 


Active Member

Posts

Joined
Wed Dec 12, 2007 2:26 pm

Post by dr770 » Wed Jun 18, 2008 8:04 am

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:

Code: Select all

if ($lang_id == 1) echo "some english content";
else if  ($lang_id == 2) echo "some german content";
which var is that?

New member

Posts

Joined
Mon Oct 15, 2007 1:53 am

Post by Luvz2drv » Wed Jun 18, 2008 8:30 am

for your tmp file to know what language you have to set it from the controller

no way around that..

Global Moderator

Posts

Joined
Fri Mar 21, 2008 10:58 am

Post by bruce » Wed Jun 18, 2008 9:47 am

My pleasure. :-) I think you are looking for something like this to put in your controller.

Code: Select all

    $view->set('lang_id', $language->getId());
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.
Last edited by bruce on Wed Jun 18, 2008 9:51 am, edited 1 time in total.

Active Member

Posts

Joined
Wed Dec 12, 2007 2:26 pm
Who is online

Users browsing this forum: No registered users and 51 guests