1

Topic: How to show avatar in main.tpl

Hi,

I want to add avatar of the current member in the main.tpl before the <pun_status>, but I can't find the way to make it, because tpl files seems to not understand PHP.

I also tried to make a new SUBST - <pun_avatar> in the header.php, or to use <pun_include "....">but still the same, I can't show the avatar of the member.

So is it possible to do it without to change lot and a lot of files, and please how ?

Thank you

Re: How to show avatar in main.tpl

Template files don't accept PHP: you need to include PHP files with pun_include

3

Re: How to show avatar in main.tpl

Hi,

Thanks, so I need to search in this way. Do you know what I need to show the avatar of the member ? Any function like pun_user[avatar] ? Or I need to create myself ? And what I need to make one ?

By the way, any documentation about all the variable of member we can call? (name, avatar, last connexion, etc ?)

Re: How to show avatar in main.tpl

$pun_user is populated by a query which grabs all the information from the users table, groups table, and some information for the online table for the current user. There's also $pun_user['is_guest'] which simply is a boolean that says if the person is a Guest or not.

5

Re: How to show avatar in main.tpl

Hi,

Thanks now I had success, here is the code I use to show avatar of the member everywhere I want in the main.tpl:

Add in include/template/main.tpl (where you want to show the avatar)

<pun_include "myfile.php">

Make a new PHP file with this code :

<?php
// Load the profile.php language file
require PUN_ROOT.'lang/'.$pun_user['language'].'/profile.php';


if ($pun_user['is_guest'])
{ // If it's a visitor, nothing...
$user_avatar = '';
}
else
{ // If it's a member
  if ($pun_config['o_avatars'] == '1' && $pun_user['show_avatars'] != '0')
    { // If the admin allowed members to use avatar AND member has an avatar
      if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$pun_user['id'].'.gif'))
      $user_avatar = '<a href="profile.php?section=personality&id='.$pun_user['id'].'"><img src="'.$pun_config['o_avatars_dir'].'/'.$pun_user['id'].'.gif" '.$img_size[3].' alt="" /></a>';
      else if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$pun_user['id'].'.jpg'))
      $user_avatar = '<a href="profile.php?section=personality&id='.$pun_user['id'].'"><img src="'.$pun_config['o_avatars_dir'].'/'.$pun_user['id'].'.jpg" '.$img_size[3].' alt="" /></a>';
      else if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$pun_user['id'].'.png'))
      $user_avatar = '<a href="profile.php?section=personality&id='.$pun_user['id'].'"><img src="'.$pun_config['o_avatars_dir'].'/'.$pun_user['id'].'.png" '.$img_size[3].' alt="" /></a>';
    }
  else
  // If the admin allowed members to use avatar AND member has NO avatar
  $user_avatar = '<a href="profile.php?section=personality&id='.$pun_user['id'].'">'.$lang_profile['No avatar'].'</a>';
}
               
// Show the result  
echo $user_avatar;
?>

RENAME your new PHP file 'myfile.php' and SAVE it to /include/user/

Re: How to show avatar in main.tpl

I tryed this but I'm getting this error

PHP Parse error:  syntax error, unexpected '<' in /home/webcoder/html/test2.php on line 29

on line 29 I have this

<pun_include "myfile.php">

7

Re: How to show avatar in main.tpl

My board can't show

// If the admin allowed members to use avatar AND member has NO avatar
  $user_avatar = '<a href="profile.php?section=personality&id='.$pun_user['id'].'">'.$lang_profile['No avatar'].'</a>';

Member no avatar      --> my board not show 'No avatar'

8

Re: How to show avatar in main.tpl

ok

this

{ // If it's a member
  if ($pun_config['o_avatars'] == '1' && $pun_user['show_avatars'] != '0')
    { // If the admin allowed members to use avatar AND member has an avatar
      if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$pun_user['id'].'.gif'))
      $user_avatar = '<a href="profile.php?section=personality&id='.$pun_user['id'].'"><img src="'.$pun_config['o_avatars_dir'].'/'.$pun_user['id'].'.gif" '.$img_size[3].' alt="" /></a>';
      else if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$pun_user['id'].'.jpg'))
      $user_avatar = '<a href="profile.php?section=personality&id='.$pun_user['id'].'"><img src="'.$pun_config['o_avatars_dir'].'/'.$pun_user['id'].'.jpg" '.$img_size[3].' alt="" /></a>';
      else if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$pun_user['id'].'.png'))
      $user_avatar = '<a href="profile.php?section=personality&id='.$pun_user['id'].'"><img src="'.$pun_config['o_avatars_dir'].'/'.$pun_user['id'].'.png" '.$img_size[3].' alt="" /></a>';
    
  else

  // If the admin allowed members to use avatar AND member has NO avatar
  $user_avatar = '<a href="profile.php?section=personality&id='.$pun_user['id'].'">'.$lang_profile['No avatar'].'</a>';

}
}

thank TLP

9

Re: How to show avatar in main.tpl

thanks a lot is working code