Welcome to the MetaMod and Chameleon Support Forums.

Before posting, please check out the FAQs.

helpme

 

Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.

 

Load metamod first time.

Load metamod first time.

Hello
I want to load metamod module only first time when user load the web site when i click any where on web site metmod module is remove or disbale. In metamod i  have write down below code for redirect web page as per country wise.
$app = JFactory::getApplication();
$session = JFactory::getSession();
$selected_lang = $session->get('chem_lang');
if ( $fromCountryId == "DE" &&  $selected_lang!="")
    $app->redirect("http://www.test.com/de/");
else if ( $fromCountryId == "ES" &&  $selected_lang=="en"){
$app->redirect("http://www.test.com/es/");
}
else if ( $fromCountryId == "FR" &&  $selected_lang!="")
    $app->redirect("http://www.test.com/fr");

Thanks
Yogesh Deshmukh

deshmukh.7177
Beginner Modder
ranks
useravatar
Offline
1 Posts
Administrator has disabled public posting

Re: Load metamod first time.

Hi Yogesh,

Can I just check what you want to happen:
What I see here is that there is some kind of redirection that happens when the system detects a certain session variable has been set (chem_lang). But I think you are saying that you only want the redirection to happen once, and after that the user is free to redirect to anywhere on the site and not get redirected again.

That's easy enough to achieve, but I suspect that the session variable may be getting set as a result of a user action like selecting a language from a dropdown or clickable element. So I wonder if you would want the user to be able to do that action again, and be redirected again? If so, we'll have to find a way to reset the redirection-blocker. Please get back to me if that's the case.

Anyway, here's the simple solution:

$app = JFactory::getApplication();
$session = JFactory::getSession();
$selected_lang = $session->get('chem_lang');
$redirected = $session->get('redirected_done');
if ($redirected) return; // return immediately, don't redirect any more.
if ( $fromCountryId == "DE" &&  $selected_lang!="") {
    $session->set("redirected_done",true);
    $app->redirect("http://www.test.com/de/");
}
else if ( $fromCountryId == "ES" &&  $selected_lang=="en"){
    $session->set("redirected_done",true);
    $app->redirect("http://www.test.com/es/");
}
else if ( $fromCountryId == "FR" &&  $selected_lang!="") {
    $session->set("redirected_done",true);
    $app->redirect("http://www.test.com/fr");
}

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3329 Posts
User info in posts
Administrator has disabled public posting

Board Info

Board Stats:
 
Total Topics:
1698
Total Polls:
6
Total Posts:
5945
Total Posts Today:
1
User Info:
 
Total Users:
5611
Newest User:
idim4
Members Online:
1
Guests Online:
124

Online: 
crooms68989

Forum Legend:

 Topic
 New
 Locked
 Sticky
 Active
 New/Active
 New/Locked
 New Sticky
 Locked/Active
 Active/Sticky
 Sticky/Locked
 Sticky/Active/Locked