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

Compare two or more links

Quote Reply
Compare two or more links
Hello!

Can I somehow compare two or more links like: http://ark.intel.com/compare/38512,52273?

Many thanks in advance.
Quote Reply
Re: [katakombe] Compare two or more links In reply to
The easiest way would be to make a new template called compare.html,. Add a new global called "do_compare", with:

Code:
sub {

my $link_id_1 = $IN->param("ID1");
my $link_id_2 = $IN->param("ID2");

if ($link_id_1 !~ /^\d+$/ || $link_id_2 !~ /^\d+$/) {

return; # dont seem to be valid

} else {

my $link1 = $DB->table("Links")->get( $link_id_1 );
my $link2 = $DB->table("Links")->get( $link_id_2 );

if ($link1->{Title} && $link2->{Title}) {

$link1 = Links::SiteHTML::tags('link', $link1);
$link2 = Links::SiteHTML::tags('link', $link2);

return { 'link1' => $link1, 'link2' => $link2 };

} else {
return;
}

}

}

Then in the new compare.html template, something like:

Code:
<%do_compare%>
Link 1 title: <%link1.Title%>
Link 2 title: <%link2.Title%>

Link 1 title: <%link1.URL%>
Link 2 title: <%link2.URL%>

Totally untested, but that should work =) Call with:

page.cgi?p=compare;ID1=1234;ID2=334

You could do it using a stand-alone script too, but the above solution should work just as well =)

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] Compare two or more links In reply to
He he he ... Wink GREAT Andy ... he he he ... Thank you!

Just one question:

How would you adapt this:

Code:
<%Plugins::ULTRAGlobals::Format_Checkbox_Field('Location',$Location)%>

<%loop checkbox_loop%>
<br /><input name="<%field_name%>" id="<%name%>" type="checkbox" value="<%name%>" <%if selected%>checked<%endif%> />
<label for="<%name%>"><%value%></label>
<%endloop%>

Once again, thanks.
Quote Reply
Re: [katakombe] Compare two or more links In reply to
Hi,

So you wanna compare those 2 loops? Mmm I guess you would need to do something like:

Code:
<%Plugins::ULTRAGlobals::Format_Checkbox_Field('Location',$link1.Location)%>
<%set checkbox_loop_1 = $checkbox_loop%>

<%Plugins::ULTRAGlobals::Format_Checkbox_Field('Location',$link2.Location)%>
<%set checkbox_loop_2 = $checkbox_loop%>

Then you would loop through each of those to give the rows you want (bit hard to give too much info, as I'm not sure if you're using tables, divs, or whatever , for your layout =))

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] Compare two or more links In reply to
PERFECT! Cool

Have a nice evening Andy!