Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.
- Index
- » MetaMod
- » MetaMod General Support
- » Display Welcome Message and a Module
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.
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
Re: Display Welcome Message and a Module
Thank you so much for helping me. Sorry I'm a dummy with this stuff
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.
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!!
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
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
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.
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
- Index
- » MetaMod
- » MetaMod General Support
- » Display Welcome Message and a Module
Board Info
- Board Stats:
- Total Topics:
- 1700
- Total Polls:
- 6
- Total Posts:
- 5967
- Posts this week:
- 3
- User Info:
- Total Users:
- 8056
- Newest User:
- no21an
- Members Online:
- 0
- Guests Online:
- 228
- 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