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.

 

Mosets Recipe

Mosets Recipe

When a registered user logs in if he has not yet created a listing I want to show a module with instructions on how to start and a welcome message.

I'm using joomla 1.5.15, Mosets 1.2, and

I would be happy with only displaying this for a user once per session.. I found the code below in the faq/forums but it just didn't work for me. My module id is 56
session_start();
/* set a different "instance name" for each module that you want to show only once */
$instance_name = "shown_module_1";
if (!isset($_SESSION[$instance_name]) ||
$_SESSION[$instance_name] == false) {
$_SESSION[$instance_name] = true;
/* customise "56" to your own module number.
  * This is the one that gets shown just once per session.
  */
return 56;
}

msquared70
Beginner Modder
ranks
useravatar
Offline
5 Posts
Administrator has disabled public posting

Re: Mosets Recipe

I'm just asking someone who knows more about Mosets Tree than I do... hope to get back to you soon.

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: Mosets Recipe

To display a module if the logged-in user has not submitted an entry, you can use the following. It only shows the module to people who are logged in but have not submitted an entry:

$userid = (int)$user->id;
if ($userid) {
  $query = "select user_id from #__mt_links where user_id = $userid";
  $db->setQuery( $query, 0, 1 );
  $found = $db->loadResult();
  if (! $found) return XXX; /* replace XXX with the module id to display */
}

If you want it to display only once, then you should be able to combine it with the session code:

$userid = (int)$user->id;
if ($userid) {
  session_start();
  /* set a different "instance name" for each module that you want to show only once */
  $instance_name = "shown_module_1";
  if (!isset($_SESSION[$instance_name]) or
      $_SESSION[$instance_name] == false) {
    $_SESSION[$instance_name] = true;
    $query = "select user_id from #__mt_links where user_id = $userid";
    $db->setQuery( $query, 0, 1 );
    $found = $db->loadResult();
    if (! $found) return XXX; /* replace XXX with the module id to display */
  }
}

Hope that helps,
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: Mosets Recipe

Thanks Stephen !!!

I really appreciate the time you put into this. Unfortunately, it causes an error for me. I did figure out your original code for showing a module once per login. I didn't have the module assignment correct.

But with the new code using module 56 and the code below. I get a blank screen. When I refresh I get an invalid token error. Then if I put the old working code in I still get a blank screen. After turning the module on/off a few times it finally start working again. But I can't get the new code to work.

Code as entered:
$userid = (int)$user->id; 
if ($userid) { 
  session_start(); 
  /* set a different "instance name" for each module that you want to show only once */ 
  $instance_name = "shown_module_1"; 
  if (!isset($_SESSION[$instance_name]) or 
      $_SESSION[$instance_name] == false) { 
    $_SESSION[$instance_name] = true; 
    $query = "select user_id from #__mt_links where user_id = $userid"; 
    $db->setQuery( $query, 0, 1 ); 
    $found = $db->loadResult(); 
    if (! $found) return 56; /* replace XXX with the module id to display */ 
  } 
}

msquared70
Beginner Modder
ranks
useravatar
Offline
5 Posts
Administrator has disabled public posting

Re: Mosets Recipe

Hi msquared70,

sorry that's not working for you... it really should!

Ok, a couple of things to check:

1 - do you have the System Cache plugin turned on in Plugin Manager? If so, I think you're going to need to turn it off. The clue for me was in the fact that you had to turn the module on and off a few times to make a difference. The System Cache plugin is a blunt instrument for caching, and assumes that all modules on a page are going to stay the same no matter who views them. So yes, there's going to be a performance hit if you turn it off. Make the best use you can of the other cache system (in the Global Configuration), because individual MetaMods can opt out of that one.

2 - it's possible that your database prefix is not "jos_" as is assumed in the recipe that I sent. Check in the Global Configuration, "Server" tab, and check out the "Database Prefix". Is it "jos_" or something else? If something else, replace the jos_ in "jos_mt_links" in the recipe with the prefix that you find there.

Hope that helps... write back if it doesn't.
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: Mosets Recipe

Hi Stephen,
I'm not sure what I'm doing wrong. Now the original version that was working is causing the same issue. Blank screen.
I checked and my cache is off and my tables do start with jos.

The module # I'm trying to display is 56 and set to a module position "meta1"
Module assigned to "ALL" and its published.

Not sure if it matters but I'm using a subdomain... its a dev. site. Could that cause issues?

mark

msquared70
Beginner Modder
ranks
useravatar
Offline
5 Posts
Administrator has disabled public posting

Re: Mosets Recipe

I think I've figured it out... I also had the plugin  "advanced module manage" installed and published. I've use that plugin for so long I had forgotten it wasn't standard. I just found yours... at one point they were working together but ultimately I guess they don't play well together or I didn't have the right combination of settings.

I unpublished Adv.Mod.Manager and now your module is doing exactly what is supposed to ... awesome.

Thank you very much

msquared70
Beginner Modder
ranks
useravatar
Offline
5 Posts
Administrator has disabled public posting

Re: Mosets Recipe

I've sent some code to Peter @ NoNumber who makes Advanced Module Manager, and together we're working on new versions of MetaMod Pro and Adv Mod Manager that will work together properly. Stay tuned!

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: Mosets Recipe

great! thanks for the info.. will look for them.

msquared70
Beginner Modder
ranks
useravatar
Offline
5 Posts
Administrator has disabled public posting

Re: Mosets Recipe

Hi Stephen, do you know if metamod and AMM working together are going to impact deeply on Joomla performance? eg adding too many queries or so...

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

Board Info

Board Stats:
 
Total Topics:
1667
Total Polls:
6
Total Posts:
5909
Total Posts Today:
1
User Info:
 
Total Users:
10075
Newest User:
rsker57
Members Online:
0
Guests Online:
156

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