Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Get data from Users other links?

Quote Reply
Get data from Users other links?
Hi,

Many of my users will be listing more than one link. Is it possible to get data to from a users previously validated link, to prefill fields on their add page with certain data? It would help lessen the user workload since some of their data may be the same for all listings.

Thanks!
Quote Reply
Re: [Jonze] Get data from Users other links? In reply to
Hi,

It could be done - but I'm not sure quite how you would work around it.

You could achieve it with a global:

Code:
sub {

my $tbl = $DB->table('Links');
$tbl->select_options('LIMIT 1',ORDER BY ID DESC');
my $link = $tbl->select( { LinkOwner => $USER->{Username} } )->fetchrow_hashref;

my $newlink;
map {
$newlink->{"Existing_".$_} = $link->{$_};
} keys %$link;

return $newlink;
}

..this should then give you the values, such as <%Existing_Title%> , <%Existing_URL%>, etc.

*totally* untested, so appologies if it doesn't work =)

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] Get data from Users other links? In reply to
Thanks! I think you've put me on the right track...

I tried the global, but so far couldn't seem to get it working.

Just to make sure I follow you, IS this the correct way to call the global??? EX: <%Existing_Title%> , <%Existing_URL%>, <%Existing_fieldname%>

If so, I get "Unknown Tag: 'fieldname'" errors. Tried a few other things but couldn't seem to get any values.

I appriciate the help...You da man Andy! =)
Quote Reply
Re: [Jonze] Get data from Users other links? In reply to
Hi,

You need to call the global first. For example, if you named it "get_other_listings" , then you would call it with:

Code:
<%get_other_listings%>

<%Existing_URL%>
<%Existing_Name%>

....etc

i.e you have to call the global first, or else it won't get run <G>

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] Get data from Users other links? In reply to
Hey mon,

Had actually tried that as well, and just tested it again for good measure. Still get a tag error...

Unknown Tag: 'Existing_Title'

add.html template:

<input type="text" name="Title" value="<%if Title%><%escape_html Title%><%else%><%existing_fields%><%Existing_Title%><%endif%>" size="50">


Thanks again!
Quote Reply
Re: [Jonze] Get data from Users other links? In reply to
Hi,

I had to rewrite it a bit - seems there were a couple of errors I didn't spot in my original global <G>

Code:
sub {

my $tbl = $DB->table('Links');
$tbl->select_options('ORDER BY ID DESC','LIMIT 1');
print $IN->header();
print qq| LinkOwner => $USER->{Username}|;

if ($tbl->count( { LinkOwner => $USER->{Username} } ) > 0) {

my $link = $tbl->select( { LinkOwner => $USER->{Username} } )->fetchrow_hashref;

my $newlink;
map {
$newlink->{"Existing_".$_} = $link->{$_};
} keys %$link;

return $newlink;
}
}

...and call with the same way - i.e <%Existing_Title%>

BTW, you only need to call <%existing_fields%> tag once =)

i.e:

Code:
<%existing_fields%>

<input type="text" name="Title" value="<%if Title%><%escape_html Title%><%else%><%Existing_Title%><%endif%>" size="50">

<input type="text" name="URL" value="<%if URL%><%escape_html URL%><%else%><%Existing_URL%><%endif%>" size="50">

That definatly works - as I just tested it on one of my own sites

CheersCool

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] Get data from Users other links? In reply to
Oh so smooth! Cool

Exactly what I had hoped to do, and works perfectly.

I'm going to get in touch with you sometime soon. As long as I make it through this years taxes. Crazy

Thanks so much Andy!