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.

 

Display Welcome Message and a Module

Display Welcome Message and a Module

Can I get some help, please and thank you.

I would like when the user logs in it displays a welcome message, eg:
if ($user->id > 0) echo "<b>Welcome, " . htmlentities($user->name) . "</b>"

And I would also like it to display module #130 but I'm not sure how to do that.

Thank you.

MyWorld
Beginner Modder
ranks
useravatar
Offline
14 Posts
Administrator has disabled public posting

Re: Display Welcome Message and a Module

Hi,

you can get it to display a module by doing a return statement at the end of the PHP code, returning the id number of the module you want to display, like this:

return 123;

So in your case, it could look like this:

if ($user->id > 0) {
  echo "<b>Welcome, " . htmlentities($user->name) . "</b>"; // don't forget that trailing ";" !!
  return 123; // display module 123. Change the ID number as required.
}

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

Re: Display Welcome Message and a Module

Thank you so much for helping me.  Sorry I'm a dummy with this stuff sad

Using the code below, when I log in I see the "Welcome" message and module #130.  But when I log out I don't see module #103.  The is the module with the login link.

What did I miss please?

Code:

if ($user->id > 103) {

  echo "<b>Welcome, " . htmlentities($user->name) . "</b>"; // don't forget that trailing ";" !!
  return 130;
}

Thank you.

MyWorld
Beginner Modder
ranks
useravatar
Offline
14 Posts
Administrator has disabled public posting

Re: Display Welcome Message and a Module

Also, is it possible to just have the first name displayed after the word "Welcome" instead of the first and last names?

When I login to the site it displays like this: Welcome, John Brown

Can I have it display like this: Welcome, John

Thank you very much!!

MyWorld
Beginner Modder
ranks
useravatar
Offline
14 Posts
Administrator has disabled public posting

Re: Display Welcome Message and a Module

Hi,

issue 1: module 130 not showing up unless the user is logged in: Sorry I assumed that was what you wanted. If you want module 130 for all users, then you could modify it to this:

if ($user->id > 0) {
  echo "<b>Welcome, " . htmlentities($user->name) . "</b>"; // don't forget that trailing ";" !!
}
return 130; // display module 130 for all users irrespective of previous statement


Secondly you ask about using the user's first name. Joomla does not record the names separately, so you would have to extract the first name from the whole name like this:

if ($user->id > 0) {
  $names = explode(" ", $user->name);
  echo "<b>Welcome, " . htmlentities(@$names[0]) . "</b>"; // don't forget that trailing ";" !!
}
return 130; // display module 130 for all users irrespective of previous statement

That should do 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
3313 Posts
User info in posts
Administrator has disabled public posting

Re: Display Welcome Message and a Module

I'm sorry but it's still not working - maybe I'm not explaining it well so let me try again. Sorry about this sad

if ($user->id > 0) {
  $names = explode(" ", $user->name);
  echo "<b>Welcome, " . htmlentities(@$names[0]) . "</b>"; // don't forget that trailing ";" !!
}
return 130; // display module 130 for all users irrespective of previous statement

So with the code above I am seeing the logout module (#130) when I am NOT logged in.  I would like to see (module #103 - the login module)

If I login, I see:  Welcome, John Brown | Logout (module #130), and this is correct.

Hope this is clearer and thank you for extracting the first name for me.

MyWorld
Beginner Modder
ranks
useravatar
Offline
14 Posts
Administrator has disabled public posting

Re: Display Welcome Message and a Module

Ok, try this then:

if ($user->id > 0) {
  $names = explode(" ", $user->name);
  echo "<b>Welcome, " . htmlentities(@$names[0]) . "</b>"; // don't forget that trailing ";" !!
  return 130; // show logout module to all these logged in users
}
return 103; // show login module to all guests

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

Re: Display Welcome Message and a Module

I'm doing the happy dance!!!  big_smile

Thank you so so much - really appreciate it.

MyWorld
Beginner Modder
ranks
useravatar
Offline
14 Posts
Administrator has disabled public posting

Board Info

Board Stats:
 
Total Topics:
1679
Total Polls:
6
Total Posts:
5913
Dormant:
User Info:
 
Total Users:
10778
Newest User:
negina4qx
Members Online:
0
Guests Online:
205

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