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.

 

Is there any way to ???

Is there any way to ???

I'm using the jCalPro calendar system and have a calendar set up for each US state (each state also has categories). What i am trying to accomplish is when the user land on the main jcalpro page is have the appropriate calendar show up using the geoip info for the state the visitor is from. Here's what if get from the advanced debug:

if (
$option == 'com_jcalpro'
and $Itemid == '368'
and JRequest::getVar('extmode') == 'cal' /*!*/
and JRequest::getVar('cal_id') == '2'
) return XXX; /* replace XXX with the module ID or position to display */

The 'cal_id' is the individual state calendar's id. I've read through the page redirection but may be making this harder than it has to be. I have several modules using the geoip data and they work fine, they display correctly, it's just the main calendar itself.

I guess my questions would be can you change or append the 'cal_id' to the end of a 'menu' url. Thanks for any suggestions or ideas on this. Steve

papageek
Beginner Modder
ranks
useravatar
Offline
2 Posts
Administrator has disabled public posting

Re: Is there any way to ???

Hi papageek,

I take it that you are trying to control the main component, and not a module?

Yes, you can do a redirection to control the main component, though it means a bit of URL manipulation to get there. You also need to ensure that you don't get stuck in an endless redirection loop.

To stop them getting stuck in an endless loop, I would suggest setting up a "spare" calendar, with a calendar ID that you don't use anywhere else. e.g. in this example, id 2. Then, set up the calendar page to use that calendar by default.

That will mean that when they click on a link to go to that page, it will go to calendar 2. The rule will pick this up, and know that it has to do the redirection to another page.

So you could try something like this:

Code:

 // test if they came in on the default page...

if ($option == 'com_jcalpro'
  and $Itemid == '368'
  and JRequest::getVar('extmode') == 'cal' /*!*/
  and JRequest::getVar('cal_id') == '2'
) {
   $cal = 3; //a valid calendar. Make it different to the "default" one to avoid redirect loops.
   if ($geoip->region == 'CA') $cal = 3;
   if ($geoip->region == 'AL') $cal = 4;
   if ($geoip->region == 'GA') $cal = 5;
   // continue with as many states as you like...

   $app = &JFactory::getApplication();
   $app->redirect( JRoute::_( 'index.php?option=com_jcalpro&Itemid=368&extmode=cal&cal_id=' . $cal));
  }

I think that will work... write back if you have any problems with it.

Cheers,
Stephen

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
3328 Posts
User info in posts
Administrator has disabled public posting

Re: Is there any way to ???

Hi thanks for the response, unfortunately I've tried the suggestion above and it always loads the default calendar. I think some of the problem is that the default view does not include the cal_id. I pasted the wrong debug info above. Here's what the debug shows on the entry page calendar.

if (
$option == 'com_jcalpro'
and $Itemid == '368'
and JRequest::getVar('extmode') == 'cal' /*!*/
) return XXX; /* replace XXX with the module ID or position to display */

And when you choose an individual calender it shows the debug info in the first post (adding the cal_id). Sorry about that. This is certainly not a show stopper but it would add a level of customization to the website. Anyways if you get a minute to think about or have another suggestion just let me know. Thanks again.

papageek
Beginner Modder
ranks
useravatar
Offline
2 Posts
Administrator has disabled public posting

Re: Is there any way to ???

Hi papageek,

I think that in the end we're not going to be able to switch the cal_id by adding it to the URL. Some components let you do that (e.g. links to individual articles obviously let you change the article id), but it looks like jCalPro does not allow this.

The only way I can think of for you to do this would be to set up a hidden menu (i.e. just normal menu, but not published as a module so it does not appear on any page), with a published menu item for each individual calendar. Then you can still use more or less the same redirect code to redirect to those pages, except you'll be changing the Itemid parameter each time rather than the cal_id parameter.

Cheers,
Stephen

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
3328 Posts
User info in posts
Administrator has disabled public posting

Board Info

Board Stats:
 
Total Topics:
1679
Total Polls:
6
Total Posts:
5933
Posts this week:
3
User Info:
 
Total Users:
4401
Newest User:
jason59312
Members Online:
0
Guests Online:
108

Online: 
There are no members online

Forum Legend:

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