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

Display last 5 submissions by logged in user

Quote Reply
Display last 5 submissions by logged in user
Hello GT community,



I would like if someone could possibly point out how to make a global that would allow to show the last 5 submissions a logged in user has made in our dbase on the home.html page.

I do not know how to write in Perl, although I can almost read it! Wink




Thanks in advance.
Quote Reply
Re: [nt6] Display last 5 submissions by logged in user In reply to
Hi,

Something like this should work;

<%global_name%>

..with code;

Code:
sub {
my $table = $DB->table('Links');
$table->select_options("ORDER BY TimeStmp","LIMIT 5");
my $sth = $table->select( { LinkOwner => $USER->{Username} } ) || return $GT::SQL::error;
my @links;
while (my $hit = $sth->fetchrow_hashref) {
push @links, $hit;
}
return { latest_non_admin_links_loop => \@links };
}

...and access with (after the global call);

Code:
<%if latest_non_admin_links_loop%>
<%loop latest_non_admin_links_loop%>
<%include link.html%>
<%endloop%>
<%endif%>

Hope that helps =)

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: Aug 13, 2005, 1:02 AM
Quote Reply
Re: [Andy] Display last 5 submissions by logged in user In reply to
Wow thanks Andy,

but does that display the last submission by the user that has logged in or just by someone who is not the admin?


I would like to show the user when he goes to home.html the last submissions he has made to the site.
Quote Reply
Re: [nt6] Display last 5 submissions by logged in user In reply to
Hi,

No problem =)

Give the above modified version a go. This will grab links based on $USER->{Username}, which should be the current user =:)

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!
Quote Reply
Re: [Andy] Display last 5 submissions by logged in user In reply to
Andy,

I am not able to have the result displayed Blush, can you please tell me exactly how to call the global in home.html? I called the global like this:

<%if latest_non_admin_links_loop%>
<%loop latest_non_admin_links_loop%>
<%include link.html%>
<%endloop%>
<%endif%>
Quote Reply
Re: [nt6] Display last 5 submissions by logged in user In reply to
You need to call the global first, or the loop won't exist Tongue

Code:
<%global_name%>
<%if latest_non_admin_links_loop%>
<%loop latest_non_admin_links_loop%>
<%include link.html%>
<%endloop%>
<%endif%>


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!
Quote Reply
Re: [Andy] Display last 5 submissions by logged in user In reply to
Thank you Andy for your time Smile