Gossamer Forum
Quote Reply
span pages
Hi there,

we are using the following global span pages:

sub {
my $top_category=shift;
my $tags=shift;
my $nh = $IN->param('nh')||1;
($nh =~ /\d+/) || ($nh=1);
my $page=$IN->param('p');
my $maxhits = $tags->{maxhits}||10;
($maxhits =~ /\d+/) || ($maxhits=10);
my $category = $DB->table('Category')->get($top_category);
my $db=$DB->table('Links','CatLinks','Category');
my $cond = GT::SQL::Condition->new('isNew', '=', 'Yes', 'Full_Name', 'like', $category->{Full_Name} . '%');
my $numhits = $db->count ( $cond );
my ($next_url, $max_page, $next_hit, $prev_hit, $left, $right, $upper, $lower, $first, $url, $last, $i);
return unless ($numhits > $maxhits);
$next_hit = $nh + 1;
$prev_hit = $nh - 1;
$max_page = int ($numhits / $maxhits) + (($numhits % $maxhits) ? 1 : 0);
$left = $nh;
$right = int($numhits/$maxhits) - $nh;
($left > 7) ? ($lower = $left - 7) : ($lower = 1);
($right > 7) ? ($upper = $nh + 7) : ($upper = int($numhits/$maxhits) + 1);
(7 - $nh >= 0) and ($upper = $upper + (8 - $nh));
($nh > ($numhits/$maxhits - 7)) and ($lower = $lower - ($nh - int($numhits/$maxhits - 7) - 1));
$url = "";
($nh > 1) and ($url .= qq~<a href="$CFG->{db_cgi_url}/page.cgi?p=$page&t=english">[<<]</a> ~);
($nh > 1) and ($url .= qq~<a href="$CFG->{db_cgi_url}/page.cgi?p=$page&nh=$prev_hit&t=english">[<]</a> ~);
for ($i = 1; $i <= int($numhits/$maxhits) + 1; $i++) {
if ($i < $lower) { $url .= " ... "; $i = ($lower-1); next; }
if ($i > $upper)
{ $url .= " ... "; last; }
($i == $nh) ? ($url .= qq~$i ~) : ($url .= qq~<a href="$CFG->{db_cgi_url}/page.cgi?p=$page&nh=$i&t=english">$i</a> ~);
if ($i * $maxhits == $numhits) { $nh == $i and $next_hit = $i; last; }
}
$url .= qq~<a href="$CFG->{db_cgi_url}/page.cgi?p=$page&nh=$next_hit&t=english">[>]</a> ~ unless ($next_hit == $nh or ($nh * $maxhits > $numhits));
$url .= qq~<a href="$CFG->{db_cgi_url}/page.cgi?p=$page&nh=$max_page&t=english">[>>]</a> ~ unless ($next_hit == $nh or ($nh * $maxhits > $numhits));
return {span=>$url,total=>$numhits};
}

The global looks for links that have a certain category, specified in <%global('1')%>. We would like to modify the global that way that we can use it for any link, not just for new one.


Cheers

Stuart
Subject Author Views Date
Thread span pages vacationrentals 2377 Mar 11, 2004, 9:15 AM
Post Re: [vacationrentals] span pages
afinlr 2302 Mar 11, 2004, 9:38 AM
Thread Re: [vacationrentals] span pages
afinlr 2322 Mar 11, 2004, 9:47 AM
Thread Re: [afinlr] span pages
Andy 2308 Mar 11, 2004, 9:55 AM
Thread Re: [Andy] span pages
afinlr 2301 Mar 11, 2004, 10:14 AM
Post Re: [afinlr] span pages
Andy 2300 Mar 11, 2004, 10:17 AM
Post Re: [afinlr] span pages
vacationrentals 2268 Mar 12, 2004, 6:37 AM