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.

 

Hide module for Second Time visitors based on cookies

Hide module for Second Time visitors based on cookies

I love your module and use it for years. Thank you very much.

Could you please help me with a code:

1-st time visitors of the page with the module stay on the page.
2-nd time visitors redirected to url

Thank you very much

Edited By: alexmartin
26-Feb-13 19:43:16

alexmartin
Junior Modder
ranks
useravatar
Offline
31 Posts
Administrator has disabled public posting

Re: Hide module for Second Time visitors based on cookies

$c = JRequest::getInt('SeenIt', 0, 'cookie');
// if cookie was set, redirect...
if ($c) {
  $app = JFactory::getApplication();
  $app->redirect("http://www.example.com/alternative_page.html");
}
// Otherwise, set the cookie and proceed as normal...
setcookie( 'SeenIt', 1, time()+60*60*24*365*10, '/' );

// Do you want to show a module here? You don't have
// to include the next line unless you need to.
return 101; /* return module 101, but only the first time */

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

Re: Hide module for Second Time visitors based on cookies

Thank you for providing me the script. I am a little bit confused on what you provided - these extra comments make me confuse ( Iam not a programmer) -should I use them and what exactly it means.
Here is the page i put the module on:

http://soloadsmasters.com/system/go.php … &url=5

On the second visit in IE 9 it does not redirects any were. Or some times it does ....after long time.

---------------------
My Metamod module is 214. and the page i am redirecting to is:
http://redirect.com/
--------------------
is that mean i should apply your code like this:  Variant 1:


$c = JRequest::getInt('SeenIt', 0, 'cookie');
// if cookie was set, redirect...
if ($c) {
  $app = JFactory::getApplication();
  $app->redirect("http://redirect.com/");
}
setcookie( 'SeenIt', 1, time()+60*60*24*365*10, '/' );

return 214;

---------------------------------------------------

.....Where 214 is that very metamod module where the code above resides?

alexmartin
Junior Modder
ranks
useravatar
Offline
31 Posts
Administrator has disabled public posting

Re: Hide module for Second Time visitors based on cookies

Hi,

there's actually no need to do the "return 214" at the end - I think that is just putting the page into an endless loop which is maybe why it's not working too well. So just leave that line out. The rest of it should work fine by itself.

In general the comments can stay in. As long as the comment starts with // or is surrounded by /* and */ then PHP will ignore it -- and it's often a good idea to keep comments in, as they help to explain what you did, next time you look at it! At least for me, anyway.

The other thing is that you might want to control which pages the MetaMod is allocated to. Only these pages will get the redirect behaviour. So you might not want to assign to ALL pages - perhaps only some pages on your site that you want people to view only once.

So just try without the return line and see how you get on...

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

Re: Hide module for Second Time visitors based on cookies

Ok, That works well. And i have extended the scenario. Here is what i need help with:
my 1-st module drops a cookie. I need to make Second - another metamod Module with ANOTHER cookie. How to make these modules to drop DIFFERENT cookies?
Please.

alexmartin
Junior Modder
ranks
useravatar
Offline
31 Posts
Administrator has disabled public posting

Re: Hide module for Second Time visitors based on cookies

I just don't know in your example above defines the cookie and if each module drop the same or different cookies?
Love your module. it save me life. Looking forward for possible help.

alexmartin
Junior Modder
ranks
useravatar
Offline
31 Posts
Administrator has disabled public posting

Re: Hide module for Second Time visitors based on cookies

Hi,

the name of the cookie in the example above is "SeenIt". This is in 2 of the lines. If you want to set up another MetaMod with a different cookie, just change that word and make sure you change it both times it is used.

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

Re: Hide module for Second Time visitors based on cookies

I found that it does workk but the problem is this cookie unterfiered with IdevAffiliate cookies. It acually disabled their cookies so Idevaffiliate no longer works correctly.

When i opened cookie file from cashe i found that metamod cooke attached at the end of Adevaffiliate cookies.

Is there any way to solve this problem?

alexmartin
Junior Modder
ranks
useravatar
Offline
31 Posts
Administrator has disabled public posting

Re: Hide module for Second Time visitors based on cookies

It's very hard to imagine that the MM cookie is actually appended to one of the other cookies (ie. appended to the cookie's value string). I would think it more likely that in the cookie cache file, you're just seeing a list of the cookies one after the other, and there's just a hidden separator.

Can you send me a URL where I can see that operating for myself?

Still, I am not disputing that it's messing things up with IdevAffiliate, but I just don't know why that would be happening. Would you like to create me a superadmin login and password, plus send me a detailed description of how it's supposed to work, and I'll take a look at it on Monday?

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

Board Info

Board Stats:
 
Total Topics:
1667
Total Polls:
6
Total Posts:
5909
Posts this week:
1
User Info:
 
Total Users:
10112
Newest User:
chris28464
Members Online:
0
Guests Online:
171

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