SimplePortal
Customization => Blocks and Modifications => Block Requests => Topic started 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.
-
<?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>';
?>
-
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.
-
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........
-
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.
<?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.
-
Not quite.
<?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.
-
Yes. That's better.