SimplePortal

Customization => Blocks and Modifications => Block Requests => Topic started by: Ahmad Rasyid Ismail on June 13, 2010, 09:45:44 AM

Title: Just Avatar Block for Member & Guest
Post by: Ahmad Rasyid Ismail on June 13, 2010, 09:45:44 AM
I wanna block that display member's avatar or guest avatar each time they logged in. And this almost the code that i want except it displays latest member avatar only. http://simpleportal.net/index.php?topic=5024.0

Here is what I wish to have for this block.
1. It will show member avatar when he logged in. If they don't have one it will display noavatar avatar with a link to update their profile and avatar if they click on it and if possible, when we hover on it, it shows text like "Click to update your profile / avatar" (for both member with or without avatar).
2. It will show guest avatar which an image with a link to join / register if they click on it. When we hover on it, it shows text like "Click here to join us now".

Please help. Thanks a million in advance.
Title: Re: Just Avatar Block for Member & Guest
Post by: ccbtimewiz on June 13, 2010, 08:43:32 PM
Code: [Select]
<?php

global $context$scripturl;

$no_avatar_image 'http://somewhere.com/noavatar.png';

if (
$context['user']['is_logged'])
echo '
<a href="' 
$scripturl '?action=profile">' . (!empty($context['user']['avatar']) ? $context['user']['avatar']['image'] : '<img src="' $no_avatar_image '" alt="" title="" />') . '</a>';
else
echo '
<a href="' 
$scripturl '?action=register"><img src="' $no_avatar_image '" alt="" title="Click here to join us now!" /></a>';

?>
Title: Re: Just Avatar Block for Member & Guest
Post by: Ahmad Rasyid Ismail on June 13, 2010, 08:51:10 PM
Great. Many thanks. I have copied and adjusted the code from portalblock.php which contain a lot of unnecessary code.  Yours is really much simpler and is very much preferred. :applause:

Thanks a million again.
Title: Re: Just Avatar Block for Member & Guest
Post by: Deezel on August 09, 2010, 03:49:31 PM
I really like this idea.
How would one create text to the left of the avy.
eg:

(If it is a member logged in)
Welcome back "User"!
Click on your avatar to access your profile.

(If it is a guest logged in)
Welcome Guest!
Click on image to Register for full access.

Just some thoughts........
Title: Re: Just Avatar Block for Member & Guest
Post by: Ahmad Rasyid Ismail on September 18, 2010, 08:46:25 AM
I think you just use the code. Just add the words / sentence you want inside the title=" ". If you need it to be shown below it, just add another echo ' yourhtmltext '; under each one that you want.

Code: [Select]
<?php

global $context$scripturl;

$no_avatar_image 'http://somewhere.com/noavatar.png';

if (
$context['user']['is_logged'])
      echo 
'
         <a href="' 
$scripturl '?action=profile">' . (!empty($context['user']['avatar']) ? $context['user']['avatar']['image'] : '<img src="' $no_avatar_image '" alt="" title="Click on your avatar to access your profile!" />') . '</a>';
      echo 
'
Welcome back "User"!<br />
Click on your avatar to access your profile.
'
;
else
   echo 
'
      <a href="' 
$scripturl '?action=register"><img src="' $no_avatar_image '" alt="" title="Click here to join us now!" /></a>';
      echo 
'
Welcome Guest!<br />
Click on image to Register for full access.
'
;

?>
For me I like to be without the text as when one hovers over it, the title that are set, will appear to show what will happen if they click on it.
Title: Re: Just Avatar Block for Member & Guest
Post by: ccbtimewiz on September 19, 2010, 06:17:11 PM
Not quite.

Code: [Select]
<?php

global $context$scripturl;

$no_avatar_image 'http://somewhere.com/noavatar.png';

if (
$context['user']['is_logged'])
{
      echo 
'
         <a href="' 
$scripturl '?action=profile">' . (!empty($context['user']['avatar']) ? $context['user']['avatar']['image'] : '<img src="' $no_avatar_image '" alt="" title="Click on your avatar to access your profile!" />') . '</a>';
      echo 
'
Welcome back "User"!<br />
Click on your avatar to access your profile.
'
;
}
else
{
   echo 
'
      <a href="' 
$scripturl '?action=register"><img src="' $no_avatar_image '" alt="" title="Click here to join us now!" /></a>';
      echo 
'
Welcome Guest!<br />
Click on image to Register for full access.
'
;
}

?>

That should work as you expected.
Title: Re: Just Avatar Block for Member & Guest
Post by: Ahmad Rasyid Ismail on September 21, 2010, 06:52:21 PM
Yes. That's better.
SimplePortal 2.3.8 © 2008-2024, SimplePortal