x
Toggle Content    Register or Login  -  January 16, 2018, 6:44 pm  
Toggle Content Commercial Themes
This is an opportunity for you to preview TCD commercial themes. All themes seen here can be purchased from the store.
Toggle Content User Info

Welcome Anonymous

Toggle Content Navigation
Toggle Content Project Status
Support Forums » DragonflyCMS » Tips & Tricks » User Avatars for modules
Please use the forum search before making a post. Your question might have been previously answered.

User Avatars for modules
Some of the best non-standard tricks for your site all in one location.


Post new topic   Reply to topic    Forum Index » Tips & Tricks Printer Friendly Page

View previous topic :: View next topic  
Author Message
Lead Developer


PostPosted: Sat May 24, 2008 9:25 pm Reply with quote

This snippet of code is for module developers. It will display all users names and avatars in a list.

Because of the way DF outputs userinfo whenever you try to display an avatar it will actually display your own instead of the actual member you want it to. This method gets around the owninfo stuff and outputs the avatars that belong to each member.

Though I did develop my own method the small bit of avatar image code was taken from the DF_Arcade module because it's better than my method.

It would be nice to see a core function created that addresses all of this stuff into one easy to use function such as get_own_avatar($avatar) or get_user_avatar($user_id). Obviously from what you see now you have to do a lot of coding yourself to get things separated for the correct output.

Code:
global $prefix, $db, $MAIN_CFG;

$sql = "
	SELECT user_id, username, user_avatar, user_avatar_type
	FROM      ".$prefix."_users
	ORDER BY username";
    $result = $db->sql_query($sql);

	$avatar_path = $MAIN_CFG['avatar']['path'];
	$avatar_gallery = $MAIN_CFG['avatar']['gallery_path'];

    OpenTable();
	echo "<table border='0' cellpadding='2' cellspacing='2'>";
	echo "<tr><td nowrap='nowrap'>Avatar</td><td nowrap='nowrap'>Username</td></tr>";
	while(list($user_id, $username, $user_avatar, $user_avatar_type) = $db->sql_fetchrow($result)){
	echo "<tr><td nowrap='nowrap'>";
	
	if ($user_avatar_type == '') {
            				$avatar = 'images/avatars/gallery/blank.gif';
        			} else if ($user_avatar_type == 1) {
            				$avatar = "$avatar_path/$user_avatar";
        			} else if ($user_avatar_type == 2) {
            				$avatar = $user_avatar;
        			} else if ($user_avatar_type == 3) {
            				$avatar = "$avatar_gallery/$user_avatar";
        			} else {
            				$avatar = 'images/avatars/gallery/blank.gif';
        			}

	echo "<img src='".$avatar."' alt='".$user_avatar."' /></td><td nowrap='nowrap'>".$username."</td></tr>"; 
	}
	echo "</table>";
    CloseTable();


_________________

Back to top
View user's profile Photo Gallery
  Page 1 of 1All times are GMT - 5 Hours

Post new topic   Reply to topic    Forum Index » Tips & Tricks Printer Friendly Page

  
  
  
 

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


RSS-News
RSS-Downloads
RSS-Forums
RSS-KnowledgeBase
Valid CSS!
Valid HTML 4.01!

Site Search | Support | Contact | Payments | Link to Us
All TCD logos and trademarks in this site are property of TreasureCoastDesigns.com
Interactive software released under GNU GPL, Code Credits, Privacy Policy
TCD_Natural © T.C.D.