Fiji Web Design
Welcome, Guest
Please Login or Register.    Lost Password?
PHP Module Code Examples (1 viewing) (1) Guest
Go to bottom Post Reply Favoured: 0
TOPIC: PHP Module Code Examples
#8
admin (Admin)
Admin
Posts: 475
graph
User Online Now Click here to see the profile of this user
PHP Module Code Examples 3 Years, 7 Months ago Karma: 10  
Show a Welcome Message to Visitors and Logged in users.

<?php

/**
* Custom code for mod_php. 
* copyright: www.fijiwebdesign.com
* Shows a welcome to the logged in user, or vistor. 
*/

global $my;

if ($my->id) {
  echo 'Hello, '.$my->username;
} else {
  echo 'Hello, visitor';
}

?>
This displays Hello, {username} or Hello, visitor based on the users logged in status.
 
Report to moderator   Logged Logged  
 
Last Edit: 2008/07/06 00:10 By admin.
  The administrator has disabled public write access.
#174
pelepaul (User)
Fresh Boarder
Posts: 4
graphgraph
User Offline Click here to see the profile of this user
Re:PHP Module Code Examples 3 Years, 5 Months ago Karma: 0  
i'm trying to use this sample to show my username. for some reason the script will only echo the 'visitor' variable of the if statement. i'm signed in as administrator. any idea why this is?
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#176
admin (Admin)
Admin
Posts: 475
graph
User Online Now Click here to see the profile of this user
Re:PHP Module Code Examples 3 Years, 5 Months ago Karma: 10  
Are you using this with Joomla 1.0 or Joomla 1.5?
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#181
pelepaul (User)
Fresh Boarder
Posts: 4
graphgraph
User Offline Click here to see the profile of this user
Re:PHP Module Code Examples 3 Years, 4 Months ago Karma: 0  
joomla 1.5. the site is www.ussa1.com. you can sign in with user name: user1 & password: password

thanks!
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#182
pelepaul (User)
Fresh Boarder
Posts: 4
graphgraph
User Offline Click here to see the profile of this user
Re:PHP Module Code Examples 3 Years, 4 Months ago Karma: 0  
the module is under the menu button: servcies
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#183
admin (Admin)
Admin
Posts: 475
graph
User Online Now Click here to see the profile of this user
Re:PHP Module Code Examples 3 Years, 4 Months ago Karma: 10  
The sample code was for Joomla1.0. Your site is using Joomla.5.

The documentation for the User Object in Joomla 1.5 is here: http://docs.joomla.org/Accessing_the_current_user_object

The code would look something like:

$user =& JFactory::getUser();
	
	if ($user->guest) {
		echo 'Hello, visitor';
	} else {
		echo 'Hello, '.$user->username;
	}
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
Go to top Post Reply
Powered by FireBoardget the latest posts directly to your desktop

Joomla Downloads

DownloadsDownload our free Joomla! Components, Modules and Plugins.