Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Building a Cool/New-Like Featured/Priority Page

(Page 2 of 2)
> >
Quote Reply
Re: [jdgamble] Building a Cool/New-Like Featured/Priority Page In reply to
This works for me:
Code:
#!/usr/local/bin/perl
#================================
use strict;
use lib '/home/pputnam/perlmad.net/cgi-bin/glinks/admin';
use Links qw/:objects/;
use Links::SiteHTML;
Links::init('/home/pputnam/perlmad.net/cgi-bin/glinks/admin');

local $SIG{__DIE__} = \&Links::fatal;

main();

sub main {
#---------------------------------------------------
#
my $pageNum = $IN->param('nh') || 1;
my $linksPP = 10;
my $start = $linksPP * $pageNum - $linksPP;
$start = ($pageNum < 2) ? 0 : $start;

my ($sth,$tab,$output);

$tab = $DB->table('Links');
$tab->select_options('ORDER BY Title', 'LIMIT ' . $linksPP . ' OFFSET ' . $start);
$sth = $tab->select( { isValidated => 'Yes', isFeatured => 'Yes' } );

my $hits = $tab->hits;

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

my $tags;
$tags->{'paging'}->{'url'} = $CFG->{db_cgi_url} . "/featured.cgi";
$tags->{'paging'}->{'num_hits'} = $hits;
$tags->{'paging'}->{'max_hits'} = $linksPP;
$tags->{'paging'}->{'current_page'} = $pageNum;
$tags->{'output'} = $output;

print $IN->header();
print Links::SiteHTML::display('featured', $tags);
}

Philip
------------------
Limecat is not pleased.
Quote Reply
Re: [fuzzy logic] Building a Cool/New-Like Featured/Priority Page In reply to
Fewww. I didn't get a chance to test any of the code, therefore agony! Crazy Thanks for testing it. I was thinking the max_hits was declared in the globals, but I guess it won't' take paging_options and paging.

Hopefully this will work : )

- Jonathan
Quote Reply
Re: [jdgamble] Building a Cool/New-Like Featured/Priority Page In reply to
OK, awesome guys! Working well now!

My last question. I would like to display on the Featured Links page all links that are EITHER isFeatured = Yes OR paid links (i.e., ExpiryDate < FREE). Right now I have a global that pulls these links properly within categories (I call this from category.html):


Code:
sub {
# Displays the featured links on each category page.
my ($id,$search_db,$output,$sth,$link);
$id = shift;
$search_db = $DB->table('Links', 'CatLinks');
$search_db->select_options ("ORDER BY Title");
my $cond = GT::SQL::Condition->new(IsFeatured => '=' => 'Yes', ExpiryDate => '<' => FREE);
$cond->bool('OR');
$sth = $search_db->select({CategoryID=>$id}, $cond);
while ($link = $sth->fetchrow_hashref) {
$output .= Links::SiteHTML::display ('link', $link);
}
return $output;
}


Here is my current featured.cgi:

Code:
#!/usr/local/bin/perl
#================================
use strict;
use lib '/var/home/moen/wiredbiz.com/cgi-bin/links/admin';
use Links qw/:objects/;
use Links::SiteHTML;
Links::init('/var/home/moen/wiredbiz.com/cgi-bin/links/admin');

local $SIG{__DIE__} = \&Links::fatal;

main();

sub main {
#---------------------------------------------------
#
my $pageNum = $IN->param('nh') || 1;
my $linksPP = 10;
my $start = $linksPP * $pageNum - $linksPP;
$start = ($pageNum < 2) ? 0 : $start;

my ($sth,$tab,$output);

$tab = $DB->table('Links');
$tab->select_options('ORDER BY Title', 'LIMIT ' . $linksPP . ' OFFSET ' . $start);
$sth = $tab->select( { isValidated => 'Yes', isFeatured => 'Yes' } );
my $hits = $tab->hits;

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

my $tags;
$tags->{'paging'}->{'url'} = $CFG->{db_cgi_url} . "/featured.cgi";
$tags->{'paging'}->{'num_hits'} = $hits;
$tags->{'paging'}->{'max_hits'} = $linksPP;
$tags->{'paging'}->{'current_page'} = $pageNum;
$tags->{'output'} = $output;

print $IN->header();
print Links::SiteHTML::display('featured', $tags);
}


So what I need to do is replace $sth = $tab->select( { isValidated => 'Yes', isFeatured => 'Yes' } ); with code that pulls all (a) all links that are validated and featured OR (b) all links that are validated and paid (i.e., ExpiryDate < FREE).

I tried stuff just to test like ExpiryDate => '< FREE' and ExpiryDate => '<> 2147483647", but no dice.

Thanks for all the help guys!
Quote Reply
Re: [Jobu] Building a Cool/New-Like Featured/Priority Page In reply to
Try this:

Code:
my $cond1 = GT::SQL::Condition->new(isValidated => "=" => "Yes");
my $cond2 = GT::SQL::Condition->new(isFeatured => "=" => "Yes", ExpiryDate => "<" => "FREE", 'OR');
my $cond3 = GT::SQL::Condition->new($cond1, $cond2);

my $sth = $tab->select($cond3);

Philip
------------------
Limecat is not pleased.
Quote Reply
Re: [fuzzy logic] Building a Cool/New-Like Featured/Priority Page In reply to
Hi,

Found that the span pages does not work correctly, links our being duplicated on page-2 and page-3 along with the span bar.
Quote Reply
Re: [jdgamble] Building a Cool/New-Like Featured/Priority Page In reply to
    

i have try to have a test for the scripts however there is no any links returned. i am not sure what is the problems it is
i am tested with latest version of linksql, however it should worked and been tested before by people.
if it is not worked with latest version of linksql? .

i am stucked now. would any one here light me a bit?

-----------------------
featured.cgi
main();
sub main {
#---------------------------------------------------
#
my $pageNum = $IN->param('nh') || 1;
my $linksPP = 10;
my $start = $linksPP * $pageNum - $linksPP;
$start = ($pageNum < 2) ? 0 : $start;
my ($sth,$tab,$output);
$tab = $DB->table('Links');
$tab->select_options('ORDER BY Title', 'LIMIT ' . $linksPP . ' OFFSET ' . $start);
$sth = $tab->select( { isValidated => 'Yes' } );
my $hits = $tab->hits;
while (my $rec = $sth->fetchrow_hashref) {
$output .= Links::SiteHTML::display('8linkfeatured', $rec);
}
my $tags;
$tags->{'paging'}->{'url'} = $CFG->{db_cgi_url} . "/featured.cgi";
$tags->{'paging'}->{'num_hits'} = $hits;
$tags->{'paging'}->{'max_hits'} = $linksPP;
$tags->{'paging'}->{'current_page'} = $pageNum;
$tags->{'output'} = $output;
print $IN->header();
print Links::SiteHTML::display('8featured', $tags);
}


----------------------

8linkfeatured.html
<%if Description%><div class="linkdescription"><%if highlight%><%Links::Tools::highlight($Description, $query)%><%else%><%Description%><%endif%></div><%endif%>


------------------------------------------
8featured.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/...ml1-transitional.dtd">
<html>
<head>
<title><%site_title%>: New Links xx</title>
<%include include_common_head.html%>
</head>
<body id="new">
<p>Here are your matching links:<br><br>

<%loop link_results_loop%>
<a href="<%URL%>"><%Title%></a>: <%Hits%>
<%endloop%>

<p><p><p><p><p>
<p>Here are your matching links:<br><br>

<%loop link_results_loop%>
<tr><td><%include 8linkfeatured.html%></td></tr>
<%endloop%>

</body>
</html>

Last edited by:

courierb: Sep 2, 2007, 10:50 PM
Quote Reply
Re: [courierb] Building a Cool/New-Like Featured/Priority Page In reply to
 i got it.
> >