Gossamer Forum
Home : Products : Gossamer Forum : Discussion :

Tags available in reply.eml

Quote Reply
Tags available in reply.eml
Hi,

I would like to use others tags than the recipient username and the recipient email address in reply.eml. I checked with <%GT::Template::dump%> and I saw that there is no others tags available for the recipient. How can I add other tags related to the recipient profil in reply.eml?

Thank you!

François
Quote Reply
Re: [Franco] Tags available in reply.eml In reply to
Hi François,

You can do this using a global. The following will provide all the user tags, prefixed with "recipient_". Eg. recipient_user_username, recipient_user_display_email, etc. After you have created the global, call it in the template:

<%global_name($parent_user_id_fk, "recipient_")%>

Code:


sub {

my ($user_id, $prefix) = @_;

$prefix ||= "";
my $user = $DB->table('User')->get($user_id) or return;
GForum::User::normalize($user);

my $return = {};


for (keys %$user) { $return->{$prefix . $_} = $user->{$_} }
$return;
}
The global sub can be used anywhere that you have a user ID.

Jason Rhinelander
Gossamer Threads
jason@gossamer-threads.com
Quote Reply
Re: [Franco] Tags available in reply.eml In reply to
I got a fatal error when I tried the global var of the last post. But Jason told me rapidly in a private message what was missing in the var. So, we should use instead this:

Code:
sub {

my ($user_id, $prefix) = @_;

$prefix ||= "";
my $user = $DB->table('User')->get($user_id) or return;
require GForum::User;
GForum::User::normalize($user);

my $return = {};


for (keys %$user) { $return->{$prefix . $_} = $user->{$_} }
$return;
}


This solution works perfectly! Thank you to Jason! I'm still always impressed by the high quality of your support! Smile

François