Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.
- Index
- » MetaMod
- » MetaMod General Support
- » How to code multiple area_codes?
How to code multiple area_codes?
How to code multiple area_codes?
I'm using a redirect based on multiple area codes, I tried the below and when adding multiple area codes it doesn't work separated by a comma, is there another character I would use to separate each area code or do I have to list each one separately?
Code:
$app = &JFactory::getApplication();
if ( $geoip->area_code == "214,817,469,972,682" )
$app->redirect("http://mydomain.com/dallas");
Thank you!
Re: How to code multiple area_codes?
Hi hominid4,
that code isn't going to work the way you think it will... you need to do it this way:
Code:
$app = &JFactory::getApplication();
$area = $geoip->area_code; // for convenience
if ( $area == "214" || $area == "817" || $area == "469" || $area == "972" || $area == "682" )
$app->redirect("http://mydomain.com/dallas");
Cheers,
Stephen
Re: How to code multiple area_codes?
Hi, one quick question regarding this. I have area codes set up for different areas of Texas and just in case none of the area codes match I have MetaMod direct them (or keep them on) to the home page with an "else $app->redirect("mydomain.com/");". The problem I having with that is it's causing a "too many redirects" error since the MetaMod is on the home page.
For those who are not redirected and stay on the home page is it possible to stop the redirects? Would I have to use the 'show the module just once' recipe?:
http://www.metamodpro.com/metamod/recip … odule-once
Thanks!
EDIT: Actually what I would need is an else statement at the end saying if you're on a computer that does not fall under one of the area codes then don't load the MetaMod module at all - is that possible? For the computers that do fall under the area codes they should never be able to access the home page. Thanks!
27-Sep-11 19:59:32
Re: How to code multiple area_codes?
Hi,
you just have the MetaMod on the home page, right?
If so, the code I gave you above should work as-is. If the area code is not matched, then no module will be displayed, and no redirection will be done. Isn't that what you want?
Cheers,
Stephen
Re: How to code multiple area_codes?
Ah, well that's embarrassing! Yes that was a fault in my thinking, I had the redirects for each region and at the end I told it that if the surfer didn't fall under any of the regions then redirect them to the home page. I see what you're saying, I just don't put an else-statement for that. Duh!
Thanks!
- Index
- » MetaMod
- » MetaMod General Support
- » How to code multiple area_codes?
Board Info
Forum Legend:
Topic
New
Locked
Sticky
Active
New/Active
New/Locked
New Sticky
Locked/Active
Active/Sticky
Sticky/Locked
Sticky/Active/Locked