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.

 

Redirect mobile devices to the main website

Redirect mobile devices to the main website

Ok I have set up a template for mobile devices on the main url.
I would like that by clicking on a link-desktop version- they could leave this mobile template and come back to the main template, then continue to surf on the main template until they click on a link -mobile version- and then continue to surf on the mobile template.

But I did not found a way of achieving this.

Any clue ? it may be useful for a lot of users ;-)

alterna
Beginner Modder
ranks
useravatar
Offline
18 Posts
Administrator has disabled public posting

Re: Redirect mobile devices to the main website

I have tried setting two menu links pointing to the home page (two aliases with two different itemids) then I set up rules to use different templates and session variables depending of which link was clicked.

But no chance so far, it seems like metatemplate would not take into account the different itemids of the aliases but consider the two menus as the same.

Is there a possibility to go this way even with sef activated ?

alterna
Beginner Modder
ranks
useravatar
Offline
18 Posts
Administrator has disabled public posting

Re: Redirect mobile devices to the main website

Hi alterna,

that's an interesting situation. I like what you're trying to do. I have a feeling that Joomla resolves the aliases, so that it only sees the "final destination" Itemid, and not the Itemid of the alias. Therefore that's not going to work, I don't think. (it was a good try though!).

Another way to do it would be to set up a dummy article. Call it "switch to mobile". Then, make a MetaTemplate rule to detect that article, and then in the SUCCEED rule, switch the template, set session variable A, and redirect to the front page. So no-one would every actually get to view the dummy page.

Then make a second rule to switch to the desired mobile template if it finds session variable A.

Then make another article for "switch to main template" and repeat the process for that one.

It may be possible to do all of this without the dummy articles, if you perhaps make the link on your page (for using mobile) as www.myserver.com?mobile=1. Then in your PHP rule you could detect like this:  if (JRequest::getInt("mobile",0) == 1) return true; else return false;  (then set up the other rules as above).

I haven't tried that it may well work. It would be great if you can report back your findings!

Cheers,
Stephen

p.s. SEF should have no effect on any of these techniques

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: Redirect mobile devices to the main website

Well I guess I need some help here.

I was able to get correct behavior from mobile to main site using the links that you suggested and to keep on the main website.

But there is no way to go back to mobile website from there. Have to wait end of session to re access the mobile one.

My rules are :


Rule 1: from mobile site to main one
if (JRequest::getInt("mobile",0) == 1) return true; else return false;
success: main template - set variable: session A - Stop processing
else:
nothing - process next

Rule 2: keep on main one
if session variable A
success: main template - Stop processing
else:
nothing - process next

Rule 3: from main site to mobile
if (JRequest::getInt("mobile",0) == 2) return true; else return false;
success: mobile template - remove variable session A - Stop processing
else:
nothing - process next

Rule 4: set template for mobile browsers
Any mobile browser
success: mobile template - stop processing
else:
nothing - stop processing

Maybe too tired but I dont see where is the problem to get rule 3 working again once we are on the main site from the mobile.

alterna
Beginner Modder
ranks
useravatar
Offline
18 Posts
Administrator has disabled public posting

Re: Redirect mobile devices to the main website

I think you need to swap the positions of rule 2 and 3. If Session variable A is set, then it will stop at rule 2 and never get to rule 3 to check for the URL parameter to swap back to the normal template.

So: (I may have the terminology confused, but it's the order that matters):

rule 1: check for main->mobile, and set session variable
rule 2: check for mobile->main, and unset session variable
rule 3: check for session variable, and if found set mobile template
rule 4: check for a mobile browser and set a mobile template if found

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: Redirect mobile devices to the main website

No in fact this is the reverse that I need:

Users will surf on the iphone with a mobile template set by metatemplate on the useragent.

Then clicking on a link will bring them to the main template, and from there clicking on a link back will cancel the session variable and bring them back to the mobile template.

Reversing my rules 2 and 3 made it for the mobile surfing !! :-)

I dont have the correct behavior from the main website but it is less important .

Any way if you have an idea to have also the correct behavior from the main website ... ?

alterna
Beginner Modder
ranks
useravatar
Offline
18 Posts
Administrator has disabled public posting

Re: Redirect mobile devices to the main website

I'm really confused now!

Is the situation described above describing how you want it to work, or how it was working before reversing the rules, or after reversing the rules?

When things get complex, I like to make a chart of all the "input" states, and what I want to happen with each of them.

Input states: (these do not necessarily correspond to rules in the rule chain; just a matrix of states and actions)

1 - someone comes to the site fresh, not with an iphone
  -- which template do I want them to have? Should this be remembered in the session?

2 - someone comes to the site fresh, on an iphone
  -- which template do I want them to have? Should this be remembered in the session?

3 - someone not on iphone is browsing, and clicks on "mobile template" link
  -- which template do I want them to have? Should this be remembered in the session?

4 - someone on iphone is browsing, and clicks on "main template" link
  -- which template do I want them to have? Should this be remembered in the session?

5 - someone on iphone is browsing, and has already clicked on "main template" link. Now they click on "mobile" link.
  -- which template do I want them to have? Should this be remembered in the session?

6 - any others?

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: Redirect mobile devices to the main website

Sorry Stephen it was 3 AM this night so my ideas was not so clear ! :-)

Anyway all is working as expected but one thing:

In order to set up a logical process, I would need in a rule to set a template, remove a session variable A and set another session variable B, this would avoid to complicate things.

Is there any chance that you could implement it ?

This way I can stop actions and trigger other ones in the same rule.

alterna
Beginner Modder
ranks
useravatar
Offline
18 Posts
Administrator has disabled public posting

Re: Redirect mobile devices to the main website

I'll be releasing an update tomorrow, so I am considering the request.

One thing that you could do however, is do a rule that detects session variable B, and if it finds it, it removes session variable A and sets the "B" template. In some of the intermediate rules you may then have session var A and B both set, but that might not matter. Still, it would be better to be able to set/cancel more than one at a time, so I understand what you're asking for.

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:
4
User Info:
 
Total Users:
4384
Newest User:
rash39381
Members Online:
0
Guests Online:
200

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