Welcome to the MetaMod and Chameleon Support Forums.

Before posting, please check out the FAQs.



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


Question before buying metamod pro

Question before buying metamod pro

With metamod, can i do the following :

Display a custom module with a PHP redirect for mobile browsers to another page. The fact is users must be redirected once (or once a week to see the page) then are no longer redirected and see normal content.


Beginner Modder
1 Posts
Administrator has disabled public posting

Re: Question before buying metamod pro


yes, you could do this with MetaMod, but I'd only do it with MetaMod if you actually want to display something in a module. Otherwise you're just using MetaMod as a way of running PHP code. I guess that's ok, but it can cause a "blank" module to be displayed in that module position.

Given a choice I'd use Chameleon to do this, for that reason. It would allow you to write code that causes redirects, and also gives you an easy way to detect mobile browsers (via a select list).

So using Chameleon I'd do it this way:

1 - in the 1st Chameleon rule, detect whether a certain cookie is set. If that cookie is set, "stop processing". i.e. bail out, don't do any redirections.

Do that with some PHP code in the PHP box:

if (JRequest::getVar("mobileredirect",'','cookie') == 1) return true; // that makes the rule SUCCEED.

2 - in the 2nd Chameleon rule, abort if the client is NOT mobile

Simply select "desktop", "tv" and "tablet" in the Browsers selection. In the Succeed action, "stop processing".

3 - if processing gets to here, then there was no cookie, and the browser is mobile. so we're going to set a cookie and do the redirect.

Don't put anything in the PHP box on the left hand side of the rule, but in the Action side there's another PHP box in the Succeed action. In that box, put the following:

setcookie( 'mobileredirect', 1, time()+60*60*24*7, '/' );

Then in the redirect box, enter the URL you want to redirect to, or select one of the pages of the site from the dropdown.

Hope that helps,

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

3330 Posts
User info in posts
Administrator has disabled public posting

Board Info

Board Stats:
Total Topics:
Total Polls:
Total Posts:
Posts this week:
User Info:
Total Users:
Newest User:
Members Online:
Guests Online:

There are no members online

Forum Legend:

 New Sticky