Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

A global to show Editors categories within UserProfiles plug in view_user_profile.html

Quote Reply
A global to show Editors categories within UserProfiles plug in view_user_profile.html
We are trying to show the categories a user is an editor for when they are editors.
We are using Andy's UserProfile plug in to display profiles.

  • Open in Google Docs Viewer
  • Open link in new tab
  • Open link in new window
  • Open link in new incognito window
  • Download file
  • Copy link address
  • Edit PDF File on PDFescape.com

Is there a simple global to do so?
Regards
KaTaBd

Users plug In - Multi Search And Remote Search plug in - WebRing plug in - Muslims Directory
Quote Reply
Re: [katabd] A global to show Editors categories within UserProfiles plug in view_user_profile.html In reply to
Hi,

So you just want to show the users categories they are editors for? If so, this should do the trick (totally untested ;))

get_editors_cats
Code:
sub {
my $sth = $DB->table("Editors")->select( { Username => $_[0] } ) || die $GT::SQL::error;

my @loop;
while (my $hit = $sth->fetchrow_hashref) {
my $cat_name = $DB->table("Category")->select( ['Full_Name'], { ID => $hit->{CategoryID} } )->fetchrow;
my $cat_url = $CFG->{build_root_url} . "/" . $DB->table("Category")->as_url( $cat_name ) . "/index.html";
push @loop, { %$hit, cat_url => $cat_url, cat_name => $cat_name };
}
my @sorted_cat = sort { $a->{cat_name} cmp $b->{cat_name} } @loop;
return { editor_cat_loop => \@sorted_loop };
}

Call with:
Code:
<%if Status eq "Editor"%>
<%get_editors_cats($user)%>
<%if editor_cat_loop%>
<a href="<%cat_url%>"><%cat_name%></a>
<%endloop%>
<%endif%>

It should sort them alphabetically for you too =)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!

Last edited by:

Andy: Mar 8, 2013, 9:51 AM
Quote Reply
Re: [Andy] A global to show Editors categories within UserProfiles plug in view_user_profile.html In reply to
Thanks,

we are getting:

Unable to compile 'get_editors_cats': Global symbol "@loop" requires explicit package name at (eval 29) line 7. Global symbol "@loop" requires explicit package name at (eval 29) line 9. Global symbol "@loop" requires explicit package name at (eval 29) line 10.
Regards
KaTaBd

Users plug In - Multi Search And Remote Search plug in - WebRing plug in - Muslims Directory
Quote Reply
Re: [katabd] A global to show Editors categories within UserProfiles plug in view_user_profile.html In reply to
Hi,

Sorry, please try the modified version. As I said, it was untested Whistle

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!