MyBB Community Forums

Full Version: Show Avatar
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello ;

I want show a defaut logo to guest and a specific logo to member but actually i have a problem :

That's my code :

<?php

if ($mybb->user['uid'] == 0)
{
echo '<img src="images/avatars/defaut.jpg" alt="Avatar" width="80px"; height="80px";style='border:1px solid #000000/>';
}

else
{
echo '<img src="{$mybb->user['avatar']}" alt="Avatar" width="80px"; height="80px";style='border:1px solid #000000' >';
}

?>

Can someone tell me what's wrong !

Thank you
Just checking, do you have the PHP conditionals in template plugin? And you do realize you are loading avatars, not a logo?
i just add this in header ..

and i find the condition in mybb.com

($mybb->user['uid'] == 0) ==> Guests
Yeah, you can't put PHP in the header unless you have the PHP in Templates plugin.
Plus, you can't use PHP like the way you are going to use. The proper syntax should be like this;

if ($mybb->user['uid'] == 0)
{
   // then do something here
}

and If you are going to use "Template Conditionals Plugin" then you've to use like this;

<if $mybb->user['uid'] == 0 then>
// do something here
Thank you guys, i will install this plugin and i will try
(2010-12-05, 11:15 AM)Yaldaram Wrote: [ -> ]Plus, you can't use PHP like the way you are going to use. The proper syntax should be like this;

if ($mybb->user['uid'] == 0)
{
   // then do something here
}

and If you are going to use "Template Conditionals Plugin" then you've to use like this;

<if $mybb->user['uid'] == 0 then>
// do something here

There are a solution to use this without any plugin ?

What i want to do is a table with three column in header, here the code :

<table width="100%" style='table-layout:fixed'>
<tr>
<td width="20%" align="left">
<div style=" color: #ffffff; text-shadow: 0 1px 0 #000;position: relative; top: 0px; left: 0px;">
{$welcomeblock}
</div>
</td>
<td width="70%" align="center">
<a href="{$mybb->settings['bburl']}"><img src="{$theme['imgdir']}/logo.png"></a>
</td>
<td width="15%" align="right">
<img src="{$mybb->user['avatar']}" alt="Avatar" width="80px"; height="80px";style='border:1px solid #000000' >';

</td>
</tr>
</table>

Welcome block membre :
<span class="smalltext" style="float:left" >
&nbsp;&curren; &nbsp;Bienvenue, {$mybb->user['username']} !<br />
&nbsp;&curren; &nbsp;Vous avez {$mybb->user['unreadpms']} MP non lus.<br />
&nbsp;&curren; &nbsp;Messages postés {$mybb->user['postnum']} .<br />
&nbsp;&curren; &nbsp;Votre réputation: {$mybb->user['reputation']} points.<br />
<a class="lellow" href="{$mybb->settings['bburl']}/member.php?action=logout&amp;logoutkey={$mybb->user['logoutkey']}">&nbsp;&curren; &nbsp;{$lang->welcome_logout}</a>
</span>

Welcome block guest :

<script type="text/javascript">
<!--
	lang.username = "{$lang->login_username}";
	lang.password = "{$lang->login_password}";
	lang.login = "{$lang->login}";
	lang.lost_password = " &mdash; <a href=\"{$mybb->settings['bburl']}/member.php?action=lostpw\">{$lang->lost_password}<\/a>";
	lang.register_url = " &mdash; <a href=\"{$mybb->settings['bburl']}/member.php?action=register\">{$lang->welcome_register}<\/a>";
	lang.remember_me = "{$lang->remember_me}";
// -->
</script>

<span class="smalltext" style="float:left;vertical-align:middle;" >&nbsp;{$lang->welcome_current_time} <br />

Bienvenue sur Geekiano, Visiteur ! &nbsp; <br />&nbsp;&nbsp;(<a href="{$mybb->settings['bburl']}/member.php?action=login" >{$lang->welcome_login}</a> &mdash; <a href="{$mybb->settings['bburl']}/member.php?action=register">{$lang->welcome_register}</a>)</span>


The problem is in the 3rd column in header :

i must use condition to show a defaut avatar to guest and member

the is any other way to do this ?
if you dont want to edit core files, you will need a plugin that uses global_start to generate the avatar path based on the UID and then make that variable global and you can then use that variable in the templates you create.