Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Adding an Avatar

Quote Reply
Adding an Avatar
I added the column Avatar under USER – so people can select an avatar to represent the user when adding a link.


I tagged it <%if Avatar%><%Avatar%><%endif%>
The avatar will only show up in Dynamic mode and only when you’re logged in.

Can someone tell me what I missed?Thanks ;)


Sandra Roussel
Chonsa Group Design - Fresh Start Housing
Quote Reply
Re: [SandraR] Adding an Avatar In reply to
You will need a global to set this up - at the moment you are only looking up the avatar of the logged in user.

Assuming your avatars are stored in /images/avatars/, and you store the filename in a column called 'Avatar', you will need a tag in your template similar to this:

Code:
<img src="/images/avatars/<%avatar($LinkOwner)%>"/>
The you need a global called 'avatar' like so:
Code:
sub {
my $in = $_[0];
my $user = $DB->table('Users')->select( ['Avatar'], {Username => $in } )->fetchrow;
}
I adapted this from another global on one of my sites so hopefully it works for you Wink.
Quote Reply
Re: [SandraR] Adding an Avatar In reply to
User details aren't provided with the link record, IIRC. You'll need to use a global using the link's LinkOwner column as the foreign key to the Users table, then you can return the Avatar column.

How about having a global that does this:

Code:
sub {
my $user = shift;
my $valid = $DB->table("Users")->get($user);

return { LinkOwnerAvatar => $valid->{Avatar} };
}

<%getUserAvatar($LinkOwner)%>

I use LinkOwnerAvatar in the example above to differentiate the avatar of the logged in user from that of the link owner.

Philip
------------------
Limecat is not pleased.