Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Featured Links on all Pages for Category...

Quote Reply
Featured Links on all Pages for Category...
Hi-

I have Featured Links for specific categories that I display in a column to the right of the main listing of links (much like the sponsored links are displayed on Google). These Featured Links are limited to 5 and are displayed with a loop and a customized link_featured.html template. I would like to have these Featured Links appear on all pages for the specific category (not just the first page of the category). Is this possible?

In other words, if the the main links are listed 10 to a page for a category, and there are 30 links in the category, then it spans 3 pages, but the 5 Featured Links I set up for the right column only appear only on the first page and not on pages 2 and 3. I would like these same 5 Featured Links to appear on all of the pages for that category. Does anyone know if there some way to accomplish this within the loop for the Featured Links, or in some other way?

Any help or ideas would be much appreciated Smile

--Frank
Quote Reply
Re: [FrankM] Featured Links on all Pages for Category... In reply to
You could probably do this with a global. You would need something like this to pass as the tag;

<%get_category_ads($ID)%>

Then a global like;

Code:
sub {

my $ID = shift;

# refeence the category list, where links are
# assigned to these categories...grab the links ID

# grab the link with the ID defined above, and
# save the HTML.

# now return the HTML, for all 5 of the links...

}

I'm literally off out now, so I'm gonna leave it with just a few pointers. If no-one has answered you when I get back, then I'll give you a more detailed routine to use Smile

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: [FrankM] Featured Links on all Pages for Category... In reply to
Hi Frank,

I wonder how you implemented the featured links like goodle does? You add a field to your links table and what else?

Thanks.

Long
Quote Reply
Re: [long327] Featured Links on all Pages for Category... In reply to
Hi Long,

I'm not very good at PERL programming so I had someone program the global for me. The cost was very reasonable. Let me know if you would like me to send you a private message with the programmer's contact info.

--Frank
Quote Reply
Re: [FrankM] Featured Links on all Pages for Category... In reply to
Hi Frank, Thank you for reply. I figured it out how to do it after some experiments. It's pretty cool. If somebody need this mod, I can post it here.

Long
Quote Reply
Re: [long327] Featured Links on all Pages for Category... In reply to
Hi,

That would be great if you could post it here. I would be interested to see how you did it, and maybe it would help others also.

--Frank
Quote Reply
Re: [FrankM] Featured Links on all Pages for Category... In reply to
This is what I did:

Sponsored link (8/27/03) -- display all links flagged as sponsor as a sparate group of links from usual links at a location of your choice in the category page


1. Add a column to the links table with the name: Sponored, column type: ENUM, default value: No (not a sponsored link)
3. Edit Build.pm, sub build_category {
Change this code

Code:
# Get the links.
my $results = $sth->fetchall_hashref;
$link_db->add_reviews ($results);
foreach my $link (@$results) {
$link->{Category_Template} = $category->{Category_Template} if ($category->{Category_Template});
$display{links} .= Links::SiteHTML::display ('link', $link);
push @{$display{links_loop}}, $link;
}


To this
Code:
# Get the links.
my $results = $sth->fetchall_hashref;
$link_db->add_reviews ($results);
foreach my $link (@$results) {
$link->{Category_Template} = $category->{Category_Template} if ($category->{Category_Template});
if ($link->{Sponsored} == 'Yes'){
$display{sponsors} .= Links::SiteHTML::display ('sponsor', $link); push @{$display{sponsors_loop}}, $link;
} else {
$display{links} .= Links::SiteHTML::display ('link', $link); push @{$display{links_loop}}, $link;
}
}

4. Add a sub to file SiteHTML.pm. You can remove something such as popular, rate

Code:
sub site_html_sponsor {
# --------------------------------------------------------
# Format a single link.
#
my $rec = shift;
(defined $Links::USER->{Username} and ($rec->{'LinkOwner'} eq $Links::USER->{Username})) ?
($rec->{'isLinkOwner'} = 1) : ($rec->{'isLinkOwner'} = 0);# Set the detailed_url.
if ($CFG->{build_detailed}) {
$rec->{detailed_url} = "$CFG->{build_detail_url}/${$rec}{'ID'}$CFG->{build_extension}";
}# Set the template set to use.
my $opts = { dynamic => 0 };
if ($rec->{Category_Template} and ($rec->{Category_Template} =~ /^[\w-]+$/)) {
$opts->{template} = $rec->{Category_Template};
}

5. Add a template named sponsors.html (copy links.html and then modify it)
6. Add this to category.html template where you want the sponsored links to appear

<!--sponsor here-->
<%if sponsors%>
<%sponsors%>
<%endif%>
<!-- end sponsor-->
7. Add a sponsored link to your links table in some cateogory to give a try.

I also want users to be able to search sponsored links and regular links separately. I have not looked into that and don't know if that is possible.

Long
Quote Reply
Re: [long327] Featured Links on all Pages for Category... In reply to
sorry this line

Code:
if ($link->{Sponsored} == 'Yes'){


should be

Code:
if ($link->{Sponsored} eq 'Yes'){


Long