Gossamer Forum
Home : Products : Gossamer Links : Discussions :

related links

Quote Reply
related links
hi

would there be a way to display related links - or shortened versions of the related links - right with link.html and detail.html?

there was an attempt to do it in Links flatfile, but there were some problems, too.

http://www.gossamer-threads.com/...orum.cgi?post=123522

thanx muchly
Quote Reply
Re: [scanreg] related links In reply to
sorry, i just don't see how to edit my original comment so i have to add another. there's no edit button.

the thing that's important about the related links feature is that it is important if you're using linkssql as a product catalog. you can cross-sell stuff that way.

muchly thanku

XXXXXXXXXXXXXXx

note: this second entry does include the edit button, but not the first entry. don't know why...

Last edited by:

scanreg: Sep 12, 2001, 12:34 PM
Quote Reply
Re: [scanreg] related links In reply to
Hi,

The tricky part would be coming up with a nice way to relate links. A quick and dirty way would be to add a field to the Links table called RelatedLinks, and make it a comma separated list of link ids. Then add a global:

display_related =>
Code:
sub {
my $tags = shift;
my @related = split /\s*,\s*/, $tags->{RelatedLinks};
return if (! @related);

my $output = '';
my $link_db = $DB->table('Links');
foreach my $related (@related) {
my $link = $link_db->get ($related) or next;
$output .= Links::SiteHTML::display('link', $link);
}
return $output;
}
Hope that helps,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] related links In reply to
Alex, you may be getting tired :)

Create a related_links table, just like cat_links.

You will need an external script to manage the related links, but all that script would need to do is accept a LinkID in, and give you room to input other related link #'s. (or browse for them). It could be extremely simple, or somewhat elegant, up to you.

Then, in the template, you simply make a function call for related links (or use a field "hasRelated" (<G> Alex... back to my flag-field emails )) and see if any exist, and if they do, format them the way you want via a loop.

Your related_link.cgi would not only allow you to enter or update related links, but could also display the links in a browse list with releated links.

The process would also work in reverse, since you can select in both directions. You could pick a "Link" and see it's related links, or a "Link" and which products it was related to, by using either the "Link" or "Related" column in the table.

To see related links to the current link:

SELECT related FROM related_links WHERE Link = LinkID

To see what links a specific product is related to:

SELECT link FROM related_links WHERE related = LinkID

Because you are only manipulating the related_links table, there would be no corruption of any of the other functions of the links process.

Going back to my email -- if there was a "hasRelated" field, then there would be a hot-link to either the script, or a pop-up form that ran the script to add the related links to the current link in the admin.

:)



PUGDOG´┐Ż Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [Alex] related links In reply to
Hi All

Alex's global works fine so far. The problem that I am having is that I can't seem to get a loop to work with this.

On the Detail page, all I want to show for the Related Links are Title, Item_Image, Description (if exists), and Add_Date

<!--BEGIN display_related LOOP-->
<b><u>Display Related</u></b><BR>
<%display_related%>
<%loop display_related_loop%>
<a href="<%db_cgi_url%>/jump.cgi?ID=<%ID%>"><%Item_Image%>&nbsp;&nbsp;<b><%Title%></b></a><BR>
<%if Description%>
<%Description%><BR>
<%endif%>
Date: <%Add_Date%><BR>
<%endloop%>
<!--END display_related LOOP-->

However, no matter what I try in the loop, I always get the whole link.html content for each Related, not my reduced loop version.

Would anyone know what the heck I am doing wrong?

Many Thanks Cool

DogTags

Quote Reply
Re: [DogTags] related links In reply to
Hi,

That's because the global is returning a string, not a loop. You could do:

display_related =>
Code:
sub {
my $tags = shift;
my @related = split /\s*,\s*/, $tags->{RelatedLinks};
return if (! @related);

my @loop;
my $link_db = $DB->table('Links');
foreach my $related (@related) {
my $link = $link_db->get ($related) or next;
push @loop, $link;
}
return { display_related_loop => \@loop }}
and then it will work as expected.

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] related links In reply to
but if i need have related links from parent category?

i mean that if link in A category, related links showing only from A category and only for example 5 related links.

please how do do it with your sub,or need enother code?



please help