• twitter image
  • facebook image
  • youtube image
  • linkedin image
Language: CMS Made Simple Czech CMS Made Simple France CMS Made Simple Spain CMS Made Simple Hungary CMS Made Simple Russia CMS Made Simple Netherlands

All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Preserve language while browsing products
PostPosted: Sat Apr 07, 2012 4:48 pm 
Offline
Forum Members
Forum Members

Joined: Wed Mar 07, 2012 4:26 pm
Posts: 19
Hi,

I am using the Products module in a multilingual e-shop like site. I 've also enabled pretty urls. Each page exists in all languages and the active language is determined from the first component of the url. If for instance it starts with 'en', the english language is used. I am using {$cgsimple->get_root_alias()} for that. So far so good.

Unfortunately, when I try to navigate from a product summary page to a product detail page the detail view is rendered using the default language of the site. Note that the rest of the page is rendered correctly using the right language and not the default. Looks like I can't pass the language info to the Products module.

By the way, the url that displays the detail looks like:
Code:
http://mydomain/Products/2/26/6

2 - is the product id
26 - is the page id
6 - ???

The are two workarounds that come to my mind but none seems appropriate. The first would be to pass the language information in the GET request. For instance, append something like "&XXXlang=en". This can't be used since i am using pretty urls. At least not without messing with the Products source code. The second would be to use a POST instead of a GET and put an additional lang parameter in the post but obviously that doesn't seem right.

Any ideas?


Top
 Profile  
 
 Post subject: Re: Preserve language while browsing products
PostPosted: Sat Apr 07, 2012 9:12 pm 
Offline
Power Poster
Power Poster
User avatar

Joined: Thu May 14, 2009 8:11 pm
Posts: 1269
Location: Lithuania
You can append any url with language parameter
Code:
...?lang={$lang}

Also it is easily to save language parameter to $_SESSION['lang'] or $_COOKIE['lang'] whenever url param "lang" is set.
It is easy to get language value
Code:
{assign var='lang' value=$smarty.session.lang}

_________________
My best friends are: FAQ: How can I debug my code/site ?...showtemplate=false...module_customhow to create a patch, {process_pagedata}
And Yours ? :)


Top
 Profile  
 
 Post subject: Re: Preserve language while browsing products
PostPosted: Sun Apr 08, 2012 5:22 pm 
Offline
Forum Members
Forum Members

Joined: Wed Mar 07, 2012 4:26 pm
Posts: 19
I appended the following
Code:
?cntnt01lang=en_US

and it worked. I had to add the 'cntnt01' first.

The only problem is that it makes 'pretty' urls kind of 'uglier'. I hope it has no effect on SEO and site crawling.

About the second solution, even if the language is saved in the session, how is it applied to the Products detail view later on? I tried to update it in both the detail template of the products and the global page template with
Code:
{assign var="lang" value=....}

but it didn't have any effect. At least not in the string literals that are taken from the module's language files. I think that somehow it has to be passed as a module parameter.


Top
 Profile  
 
 Post subject: Re: Preserve language while browsing products
PostPosted: Mon Apr 09, 2012 10:15 am 
Offline
Power Poster
Power Poster
User avatar

Joined: Thu May 14, 2009 8:11 pm
Posts: 1269
Location: Lithuania
There were 2 option on using/passing values, not 2 solutions.

Quote:
...I think that somehow it has to be passed as a module parameter.

If you create page that displays Products detail template depending on url you can use saved language
Code:
{Products action='details' productid=$productid_from_url lang=$smarty.session.lang}
Similar function with url
Code:
{Products action='details' productid=$productid_from_url lang=$smarty.get.lang}


$productid_from_url can be url param or value extracted with regexp or mod_rewrite on htaccess. It is just another variable like language

'cntn01' is default action id. It means Products module is displayed on whole content block. If you have uncommon layout it will not work the way you expect.

As for SEO, Google will understand any link you throw to it. If there are more than one valid link to the same page it will chose the shortest one. Further more it might index your summary pages only providing they contain 99% of all useful info. But that is another story.

_________________
My best friends are: FAQ: How can I debug my code/site ?...showtemplate=false...module_customhow to create a patch, {process_pagedata}
And Yours ? :)


Top
 Profile  
 
 Post subject: Re: Preserve language while browsing products
PostPosted: Tue Apr 10, 2012 1:43 pm 
Offline
Forum Members
Forum Members

Joined: Wed Mar 07, 2012 4:26 pm
Posts: 19
:o

That explains a lot, in particular using $smarty.get variable. So, one can easily pass normal parameters to the url and access them through $smarty.get."paramname" in the page templates.

You've been most helpful. Thanks.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC


Who is online

Users browsing this forum: sandaha


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Arvixe - A CMSMS Partner