Dynamic get collection page ID - Form

Permalink
Hi,

I need to be able to define ID of a page depending of the international section the visitor is in.

On homepage i have a small Check Availability form that redirect to a specific page which should be different for each language section of the website.
This is my form Action :
action="<?php echo DIR_REL . "/index.php" . Page::getCollectionPathFromID(198); ?>"


For exemple for English section the line is
Page::getCollectionPathFromID(198);

For French i need to get this :
Page::getCollectionPathFromID(391);


So i need to be able to dynamic change regarding the language this part [Page::getCollectionPathFromID(198);[/code] in the link.

Any ideas will be warm welcome.

Check this link to see what i'm talking about :
http://http://www.sanctuaryhotelsandresorts.com


Kind regards

Chris

chrismodlao
 
hutman replied on at Permalink Reply
hutman
You could do something like this:

$languageCode = Loader::helper('section', 'multilingual')->getLanguage();
if (strlen($languageCode) === 5) {
   $languageCode = substr($languageCode, 0, 2);
}


This would leave you with something like "en" in the $languageCode and you could either hard code your cID based on that, or you could do a switch and put the full url link in there.
chrismodlao replied on at Permalink Reply
chrismodlao
Hi,

I'm not sure that's what i need.
In fact i need to test the actual language (english or french or lao or chinese) and change the form Action regarding this.

@Hutman : Thanks for this trick anyway.

Chris
hutman replied on at Permalink Reply
hutman
I think this would still work for you, you would just have to do something like this

$languageCode = Loader::helper('section', 'multilingual')->getLanguage();
if (strlen($languageCode) === 5) {
   $languageCode = substr($languageCode, 0, 2);
}
switch($languageCode){
   case 'en':
      $action = DIR_REL . "/index.php" . Page::getCollectionPathFromID(198);
      break;
   case 'fr':
      $action = DIR_REL . "/index.php" . Page::getCollectionPathFromID(391);
      break;
}
action="<?php echo $action; ?>"


Then you could setup each page you wanted to redirect to by the language string that will be shown in that section of the site.

If this isn't what you're looking for maybe a more clear idea of what you are trying to do would be helpful.
chrismodlao replied on at Permalink Reply
chrismodlao
Hi,

Thanks that's i guess exactly what i need.

But i need a small more information to setup this snippet.
COuld you explain me

switch($languageCode){
        case 'en':

or this one :
switch($languageCode){
        case 'fr':


This EN and FR should refere to the SubFolder of the language or should refere of the abbreviation the multilingual system is using :

en_GB
fr_FR
zh_CN
... etc ...


Thanks in advance

Chris
hutman replied on at Permalink Reply
hutman
It'll be the first two letters of the multilingual system code.
chrismodlao replied on at Permalink Reply
chrismodlao
Thanks a lot, have a nice day.

Chris