Topic: How get the user's avatar path ?

Hi everybody, I'm new in Punbb world.
I try to intergrate the forum in my site, but I have some problems.

I search how to get the avatar of the user who is connected. (To show it in the logbox).
Where I can find it ?

PS : I just want the path to the avatar, not a html code like <img src="[...]"/>.

Thanks for answers.
Thaledric

2

Re: How get the user's avatar path ?

This?
<li class="useravatar"><img src="http://punbb.es/img/avatars/USERID.jpg" width="100" height="100" alt="username" /></li>
I can´t find de php code

Re: How get the user's avatar path ?

Yes, it looks to be that kind of files.
Is USERID a defined constant ?

4

Re: How get the user's avatar path ?

La USERID es la "identificación" de los miembros del Foro
Por ejemplo:
http://punbb.es/user5.html
El 5 es la ID del usuario de ese Perfil, todo lo que valla a él será con esa ID, por ejemplo al buscar sus Topics
http://punbb.es/search-posts-user5.html
O al enviar un Email
http://punbb.es/pun_pm-compose-5.html

La ID la encontrarás en los archivos que estén los templates de PunBB, buscando en los archivos php.

Te ayudaría mucho mejor si me dijeses que quieres hacer exactamente y para qué
Saludos y perdona mi inglés, Google Traductor xD
__________________________________________________________________________________________
The user is the "identification" of the members of the Forum
For example:
http://punbb.es/user5.html
The 5 is the user ID of the profile, all that he will fence with that ID, for example, to search for your topics
http://punbb.es/search-posts-user5.html
Or send an Email
http://punbb.es/pun_pm-compose-5.html

The ID is found in the files that are templates for PunBB, searching the php files.

Help you better if you want to tell me exactly and what
Greetings and excuse my english, Google translator xD

Re: How get the user's avatar path ?

Hum.... In my .tpl files, I've just html code, not php.
If USERID is a constant, I wanna to konw where she's declared.
Because if I seach "USERID" in my forum directory, I have no results...

So I hope there is a variable which contains the current user's id.

What I want to do is that :
<div id="logbox_avatar" style="bacrground-image : url(AVATAR_PATH);"></div>

AVATAR_PATH is the url of the current user's avatar, so it looks to that : "./img/avatar/USERID.AVATAR_EXT"

USERID is the current user's ID (you had guessed? ^^).
AVATAR_EXT is the file extention of the current user's avatar (.png, .gif or .jpg).

I've learned about punsapi, a tool for make the integration of punbb easier, but this is not compatible with punbb 1.4...

Sorry for my bad spannish (google translator), and my bad english (I'm french ^^).
__________________________________________________________________

Hum .... En mi archivos .tpl, acabo de código html, no php.
Si USERID es una constante, quiero saber dónde está declarado.
Porque si busquo "UserID" en mi directorio del foro, no tengo resultados ...

Así que espero que haya una variable que contiene el id del usuario actual.

Lo que quiero hacer es lo siguiente:
<div id="logbox_avatar" style="bacrground-image: url(AVATAR_PATH);"> </ div>

AVATAR_PATH es la url del avatar del usuario actual, por lo que parece a lo siguiente: "./img/avatar/USERID.AVATAR_EXT"

USERID es el ID del usuario actual (que había adivinado ? ^^).
AVATAR_EXT es la extensión del archivo del avatar del usuario actual (.png, .gif o .jpg).

Que he aprendido sobre punsapi, una herramienta para hacer más fácil la integración de punbb, pero esto no es compatible con punbb 1.4 ...

Lo siento por mi mala spannish (Google translator), y mi mala Inglés (soy francés ^^).

Re: How get the user's avatar path ?

Follow instructions here: http://punbb.informer.com/wiki/punbb13/ … on#general (in "General" section).

Then in your code, something like:

<div id="logbox_avatar" style="bacrground-image : url(<?php echo "./img/avatar/" . $forum_user['id'] . '.AVATAR_EXTENSION'); ?>;"></div>

The above code has some problems (what if user is guest, what about different extension types) but I have to get going for a bit. It should get you started though.

Re: How get the user's avatar path ?

Are you trying to do something like this? If yes, I think I can help.

Re: How get the user's avatar path ?

In PunBB 1.4 avatar handling fucntion is changed. Better look into source code.

9 (edited by hoang83vu 2012-01-30 18:09)

Re: How get the user's avatar path ?

dimkalinux wrote:

In PunBB 1.4 avatar handling fucntion is changed. Better look into source code.

This is true. When I was playing with it, I realized the PunBB 1.4 is totally different to version 1.3. Better read the code, and PunBwiki only supports 1.3.

Re: How get the user's avatar path ?

Well, for simplify, I just want a variable who contains the url of the current user's avatar.
Like this : $avatar_path = 'img/avatars/2.png';

Obviously, I want it work for every file extension...

Thanks everybody for your help !

11 (edited by hoang83vu 2012-01-30 20:15)

Re: How get the user's avatar path ?

When I made my theme, I figured out that there was not a full path for your avatar. You would need to custom make the path with function calls provided in PunBB.

<a href="<?php echo forum_link($forum_url['user'],$forum_user['id']); ?>"><img id="avatar" src="<?php echo($base_url); ?>/<?php echo($forum_config['o_avatars_dir']); ?>/<?php echo($avatar_filename); ?>" /></a>

This would produce an <a> tag with an image avatar. Hope it helps.

Re: How get the user's avatar path ?

Hum... your script doesn't work...
$avatar_filename is not declared...

There's any $forum_user['---'] variable who contains the avatar filename ?

Re: How get the user's avatar path ?

Thaledric wrote:

Hum... your script doesn't work...
$avatar_filename is not declared...

There's any $forum_user['---'] variable who contains the avatar filename ?

Sorry I was too clumsy. Here is the entire code for it

<?php
    switch ($forum_user['avatar'])
    {
        case FORUM_AVATAR_GIF:
            $avatar_filename = $forum_user['id'].'.gif';
            break;

        case FORUM_AVATAR_JPG:
            $avatar_filename = $forum_user['id'].'.jpg';
            break;

        case FORUM_AVATAR_PNG:
            $avatar_filename = $forum_user['id'].'.png';
            break;

        case FORUM_AVATAR_NONE:
            $noavatar = TRUE;
            break;
        default:
            $noavatar = TRUE;
            break;
    }
?>

Re: How get the user's avatar path ?

Okay, it works !
Thanks, very well !

Oh, a last question : is there a documentation where I can find all the punbb globals ?
Thanks again !

Re: How get the user's avatar path ?

I dont know about that. Try to check Punbbwiki then. Hope it will help.

Re: How get the user's avatar path ?

I've already done it. There's just exmaples, but not a complete list of them...