Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Links SQL 2.x Problem with SPAN Pages

Quote Reply
Links SQL 2.x Problem with SPAN Pages

Hi,

I have a Problem with SPAN Pages while I try to make the navbar a little bit smarter.

This is my Code in build.pm and in red are my changes but now I did not find where
I have to change the code for the actual page. See the attached Images please.

Code:
$SUBS{build_toolbar} = <<'END_OF_SUB';
sub build_toolbar {
# --------------------------------------------------------
# Create an Altavista style toolbar for the next and previous pages.
#
my $opts = shift;


my $root_url = $opts->{url};
my $first_url = $opts->{first_url} || ($root_url . '/' . $CFG->{build_index});
my $next_url = $opts->{next_url} || ($root_url . '/more');
my $numhits = $opts->{numlinks};
my $nh = $opts->{nh};
my $maxhits = $opts->{mh} || $CFG->{build_links_per_page};


my ($next_hit, $prev_hit, $left, $right, $upper, $lower, $url, $i);
$next_hit = $nh + 1;
$prev_hit = $nh - 1;


# First, set how many pages we have on the left and the right.
$left = $nh; $right = int($numhits/$maxhits) - $nh;
# Then work out what page number we can go above and below.
($left > 7) ? ($lower = $left - 7) : ($lower = 1);
($right > 7) ? ($upper = $nh + 7) : ($upper = int($numhits/$maxhits) + 1);
# Finally, adjust those page numbers if we are near an endpoint.
(7 - $nh >= 0) and ($upper = $upper + (8 - $nh));
($nh > ($numhits/$maxhits - 7)) and ($lower = $lower - ($nh - int($numhits/$maxhits - 7) - 1));
$url = "";


# Then let's go through the pages and build the HTML.
($nh > 1) and (($nh == 2) ? ($url .= qq~<li><a href="$first_url">zur&uuml;ck</a></li> ~) : ($url .= qq~<li><a href="$next_url$prev_hit$CFG->{build_extension}">zur&uuml;ck</a></li> ~));
for ($i = 1; $i <= int($numhits/$maxhits) + 1; $i++) {
if ($i < $lower) { $url .= " ... "; $i = ($lower-1); next; }
if ($i > $upper) { $url .= " ... "; last; }
if ($i == 1) { ($i == $nh) ? ($url .= qq~$i ~) : ($url .= qq~<li><a href="$first_url">$i</a></li> ~); }
else { ($i == $nh) ? ($url .= qq~$i ~) : ($url .= qq~<li><a href="$next_url$i$CFG->{build_extension}">$i</a></li> ~); }
if ($i * $maxhits == $numhits) { $nh == $i and $next_hit = $i; last; }
}


$url .= qq~<li><a href="$next_url$next_hit$CFG->{build_extension}">weiter</a></li> ~ unless ($next_hit == $nh or ($nh * $maxhits > $numhits));


return $url;
}
END_OF_SUB


Best regards from
Bremen/Germany

Lothar
Quote Reply
Re: [eljot] Links SQL 2.x Problem with SPAN Pages In reply to


Best regards from
Bremen/Germany

Lothar
Quote Reply
Re: [eljot] Links SQL 2.x Problem with SPAN Pages In reply to
Sorry, not sure what you are asking?

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] Links SQL 2.x Problem with SPAN Pages In reply to
Hi Andy, Do you see the Page No. 9 on the screenshot?
This is the actual page and it is outside and not in the list Frown

Best regards from
Bremen/Germany

Lothar

Last edited by:

eljot: Jun 28, 2015, 1:46 AM
Quote Reply
Re: [eljot] Links SQL 2.x Problem with SPAN Pages In reply to
Are you on page 9 when this happens? Or another page?

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: [eljot] Links SQL 2.x Problem with SPAN Pages In reply to
Ok, I see it. Try changing

Code:
if ($i == 1) { ($i == $nh) ? ($url .= qq~$i ~) : ($url .= qq~<li><a href="$first_url">$i</a></li> ~); }

to

Code:
if ($i == 1) { ($i == $nh) ? ($url .= qq~<li><a href="#">$i</a></li> ~) : ($url .= qq~<li><a href="$first_url">$i</a></li> ~); }

That should fix it :)

Basically, its the "current" page (that normally prints just as a plain number), that was getting outputted- and because this was within a <ul> element, it got added right at the end (as it was not a correct <li></li> element within <ul>)

Angelic

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] Links SQL 2.x Problem with SPAN Pages In reply to
Thanks a lot Andy. You saved my day!

I changed also the next line:


Code:
else { ($i == $nh) ? ($url .= qq~$i ~) : ($url .= qq~<li><a href="$next_url$i$CFG->{build_extension}">$i</a></li> ~); }


to


Code:
else { ($i == $nh) ? ($url .= qq~<li><a href="#">$i</a></li> ~) : ($url .= qq~<li><a href="$next_url$i$CFG->{build_extension}">$i</a></li> ~); }


Best regards from
Bremen/Germany

Lothar
Quote Reply
Re: [eljot] Links SQL 2.x Problem with SPAN Pages In reply to
and one more thing to change is, set the <li> as active
to get this result on the active page.




if anyone like to do the same ;)

if ($i == 1) { ($i == $nh) ? ($url .= qq~<li class="active"><a href="#">$i</a></li> ~) : ($url .= qq~<li><a href="$first_url">$i</a></li> ~); }
else { ($i == $nh) ? ($url .= qq~<li class="active"><a href="#">$i</a></li> ~) : ($url .= qq~<li><a href="$next_url$i$CFG->{build_extension}">$i</a></li> ~); }

Best regards from
Bremen/Germany

Lothar
Quote Reply
Re: [eljot] Links SQL 2.x Problem with SPAN Pages In reply to
sorry missed to place the code as code


Code:
if ($i == 1) { ($i == $nh) ? ($url .= qq~<li class="active"><a href="#">$i</a></li> ~) : ($url .= qq~<li><a href="$first_url">$i</a></li> ~); }
else { ($i == $nh) ? ($url .= qq~<li class="active"><a href="#">$i</a></li> ~) : ($url .= qq~<li><a href="$next_url$i$CFG->{build_extension}">$i</a></li> ~); }

Best regards from
Bremen/Germany

Lothar
Quote Reply
Re: [eljot] Links SQL 2.x Problem with SPAN Pages In reply to
Glad I could help Angelic

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!