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

last5 global by linkowner?

Quote Reply
last5 global by linkowner?
I've already been using the global for the "last 5 links", but how to make a global for the lastn by user? Or would this have to be more specific than a global?
Quote Reply
Re: [SSmeredith] last5 global by linkowner? In reply to
This would be useful for a visitor to "Read all posts by this user" or "View all links by this User"

Last edited by:

SSmeredith: Jun 2, 2003, 7:42 AM
Quote Reply
Re: [SSmeredith] last5 global by linkowner? In reply to
Inside the 'last n links', you would just need to put something like;

select ( { LinkOwner => $linkowner } );

...and pass some extra details to the routine. Like;

<%last_x($LinkOwner)%>

with that value being passed via;

my $LinkOwner = shift;

If you paste the global you are using, I could make these changes for you. I just don't know which version your are using Tongue

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] last5 global by linkowner? In reply to
HI Andy,

This is what I have...

sub {
my $vals = shift;
my $link_db = $DB->table ('Links');
$link_db->select_options ('ORDER BY ID DESC', 'LIMIT 6');
my $sth = $link_db->select( { isNew => "Yes", isValidated => "Yes" } );
my $output = '';
while (my $link = $sth->fetchrow_hashref) {
$output .= Links::SiteHTML::display('link', $link);
}
return $output;
}

Not using it yet, so I can work with changes

Thanks!
Quote Reply
Re: [SSmeredith] last5 global by linkowner? In reply to
something like this should work then;

Code:
sub {
my $LinkOwner = shift;

my $link_db = $DB->table ('Links');
$link_db->select_options ('ORDER BY ID DESC', 'LIMIT 6');
if ($LinkOwner) {
my $sth = $link_db->select( { isNew => "Yes", isValidated => "Yes", LinkOwner => $LinkOwner } );
} else {
my $sth = $link_db->select( { isNew => "Yes", isValidated => "Yes" } );
}

my $output = '';

while (my $link = $sth->fetchrow_hashref) {
$output .= Links::SiteHTML::display('link', $link);
}
return $output;
}

Call with;

<%global_name($LinkOwner)%>

If no link owner is specified, it will just check for normal new links. So to show the last 6 links, by anyone, you could use;

<%global_name%>

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] last5 global by linkowner? In reply to
okay, I'll give it a try -

One question - how to state which user's links I want to appear?

What I mean is who's - Andy's, Mine, Dick's, Jane's... you know ?


Should I have asked for a global to see all links by that USER?

Last edited by:

SSmeredith: Jun 2, 2003, 10:01 AM
Quote Reply
Re: [SSmeredith] last5 global by linkowner? In reply to
To see a specific person, just use something like;

<%global_name("Andy")%>

<%global_name("Merdith")%>

<%global_name("Dick")%>

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] last5 global by linkowner? In reply to
Excellent, glad I asked!

Thanks again!

M
Quote Reply
Re: [Andy] last5 global by linkowner? In reply to
Hi Andy,

I am getting error "unable to compile globalname" while trying to use this global.

Do you know what might be wrong.

Thanks
Quote Reply
Re: [cassandra] last5 global by linkowner? In reply to
Mmm..that may have something to do with the 'my' inside the 'if' statement. Give this one a go;

Code:
sub {
my $LinkOwner = shift;
my $sth;

my $link_db = $DB->table ('Links');
$link_db->select_options ('ORDER BY ID DESC', 'LIMIT 6');
if ($LinkOwner) {
$sth = $link_db->select( { isNew => "Yes", isValidated => "Yes", LinkOwner => $LinkOwner } );
} else {
$sth = $link_db->select( { isNew => "Yes", isValidated => "Yes" } );
}

my $output = '';

while (my $link = $sth->fetchrow_hashref) {
$output .= Links::SiteHTML::display('link', $link);
}
return $output;
}

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] last5 global by linkowner? In reply to
my $string = qq{that may have something to do with the 'my' inside the 'if' statement};
$string =~ s/may/does/;

Last edited by:

Paul: Jun 3, 2003, 9:03 AM
Quote Reply
Re: [Paul] last5 global by linkowner? In reply to
LOL...you have such a 'lovely' way of putting things Sly

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] last5 global by linkowner? In reply to
Hi Andy,

Its working fine, but one small problem.

I am using this global on a detail page. It's showing all the 5 New links from the LinkOwner including the one on the Detail page.

I want to display 5 Links except the one on the detail page.

I appreciate your help

Thanks.