Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Changing the design of <%span%>

Quote Reply
Changing the design of <%span%>
In the category template -

<font color=
"#FFFFFF" face="verdana" size="2">Pages: <%next_span%></font></font><br>

the font tag doesn't affect the <%span%> or <%next_span%> - they automatically take on the same attributes as all links (from the CSS). I want them to have different attributes - how can I do that? I can't see any template or global where the <%span%> and <%next_span%> are defined.

Thanks

If you love cats - visit www.TheCatSite.com

Visit my LinkSQL based Cat Site - www.Meowhoo.com
Quote Reply
Re: [Anat] Changing the design of <%span%> In reply to
The next_span tag is built in Links::Build::build_toolbar. If you want to change the look of the toolbar, you can either

a) change the code in Links::Build::build_toolbar (just put class="yourclass" wherever you see <a href=""> .... The advantage of this method is that it doesn't take much work to do, the disadvantage is that you will have to do it again when you upgrade to a newer version of Links SQL.

or

b) write a plugin that changes the look of the toolbar. Advantage: no problems with upgrade

or

c) use this global
Code:
sub {
my $next_span = shift;
$next_span =~ s,(href=".+?"),$1 class="my_class",g;
return $next_span;
}
Call the global as <%my_next_span($next_span)%>.

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] Changing the design of <%span%> In reply to
Sorry, just got around to actually trying this. I can't see any "build toolbar" option in Links SQL. I'd rather play around with templates than globals if at all possible.

If you love cats - visit www.TheCatSite.com

Visit my LinkSQL based Cat Site - www.Meowhoo.com
Quote Reply
Re: [Anat] Changing the design of <%span%> In reply to
Would something like this work for you?
Code:
<DIV CLASS="pages">Pages: <%next_span%> </DIV>
Specify how you want DIV.pages to look in your style sheet.
Quote Reply
Re: [YoYoYoYo] Changing the design of <%span%> In reply to
nope - doesn't do the trick

Somewhere in the definition of what %span% is it uses the "a href" tag and that draws it's style from another line in the CSS and overrides the div apparently.

If I could get to where that "a href" of the %span% is I could change the style through there - but I can't find it Unsure



Anne

If you love cats - visit www.TheCatSite.com

Visit my LinkSQL based Cat Site - www.Meowhoo.com
Quote Reply
Re: [Anat] Changing the design of <%span%> In reply to
Look in

../admin/Links/Build.pm
sub build_toolbar
sub build_search_toolbar

and

../admin/GT/SQL/Display/HTML.pm
sub toolbar
Quote Reply
Re: [Anat] Changing the design of <%span%> In reply to
Hi!

Try with:



<%if next_span%>
<TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
<TR>
<TD class="NEXTSPAN">
&nbsp; Pages: <%next_span%>
</TD>
</TR>
</TABLE>
<%endif%>



CSS:


.NEXTSPAN A {COLOR: #FF6633; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; font-weight:bold}
.NEXTSPAN A:link {COLOR: #FF6633; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; font-weight:bold}
.NEXTSPAN A:visited {COLOR: #FF6633; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; font-weight:bold}
.NEXTSPAN A:active {COLOR: #FF6633; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; font-weight:bold}
.NEXTSPAN A:hover {COLOR: #CCCCCC; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; font-weight:bold}
.NEXTSPAN {COLOR: #000000; FONT-FAMILY: Verdana; FONT-SIZE: 9pt; font-weight:bold}



<%next_span%> is created by Links>Build.pm

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



I hope so!Wink







Use table and CSS because it is safer, when you upgrade to a new version of LSQL ...

You will have to change this again.

It works fine for me.


(Sorry YoYoYoYo - didn't see your post - so it is Build.pm Wink)

Last edited by:

Payooo: Aug 20, 2002, 7:16 AM
Quote Reply
Re: [Payooo] Changing the design of <%span%> In reply to
Unsure still doesn't work for me

I tried the table but it didn't work and it made the bar look too high (or wide)

then I went to the code and made these changes:

In Build.pm -

Code:


I changed the code into:

Code:
# Create an Altavista style toolbar for the next and previous pages.
#
my $opts = shift; my $root_url = $opts->{url};
my $numhits = $opts->{numlinks};
my $nh = $opts->{nh};
my $mh = $opts->{mh};



my ($next_hit, $prev_hit, $maxhits, $left, $right, $upper, $lower, $url, $i);

$maxhits = $mh || $CFG->{build_links_per_page};
$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 ($url .= qq~<a href="$root_url&nh=$prev_hit" class="spages">[<<]</a> ~);
for ($i = 1; $i <= int($numhits/$maxhits) + ( $numhits % $maxhits ? 1 : 0 ); $i++) {
if ($i < $lower) { $url .= " ... "; $i = ($lower-1); next; }
if ($i > $upper) { $url .= " ... "; last; }
($i == $nh) ? ($url .= qq~$i ~) : ($url .= qq~<a href="$root_url&nh=$i" class="spages">$i</a> ~);
if ($i * $maxhits == $numhits) { $nh == $i and $next_hit = $i; last; }
}
$url .= qq~<a href="$root_url&nh=$next_hit" class="spages">[>>]</a> ~ unless ($next_hit == $nh or ($nh * $maxhits > $numhits));
return $url;
}
END_OF_SUB


In HTML.pm I made these changes

Original code:

Code:

sub toolbar {
# ---------------------------------------------------------------
# Display/calculate a "next hits" toolbar.
#
my $class = shift;
my ($nh, $maxhits, $numhits, $script) = @_;
my ($next_url, $max_page, $next_hit, $prev_hit, $left, $right, $upper, $lower, $first, $url, $last, $i);# Return if there shouldn't be a speedbar.
return unless ($numhits > $maxhits); # Strip nh=\d out of the query string, as we need to append it on. Try and keep
# the url looking nice (i.e. no double ;&, or extra ?.
$script =~ s/[&;]nh=\d+([&;]?)/$1/;
$script =~ s/\?nh=\d+[&;]?/\?/;
($script =~ /\?/) or ($script .= "?");
$script =~ s/&/&amp;/g;
$next_hit = $nh + 1;
$prev_hit = $nh - 1;
$maxhits ||= 25;
$max_page = int ($numhits / $maxhits) + (($numhits % $maxhits) ? 1 : 0);# 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 ($url .= qq~<a href="$script;nh=1">[&lt;&lt;]</a> ~);
($nh > 1) and ($url .= qq~<a href="$script;nh=$prev_hit">[&lt;]</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="$script&amp;nh=$i">$i</a> ~);
if ($i * $maxhits == $numhits) { $nh == $i and $next_hit = $i; last; }
}
$url .= qq~<a href="$script;nh=$next_hit">[&gt;]</a> ~ unless ($next_hit == $nh or ($nh * $maxhits > $numhits));
$url .= qq~<a href="$script;nh=$max_page">[&gt;&gt;]</a> ~ unless ($next_hit == $nh or ($nh * $maxhits > $numhits));
return $url;
}


Changed code:

In Reply To:



sub toolbar {
# ---------------------------------------------------------------
# Display/calculate a "next hits" toolbar.
#
my $class = shift;
my ($nh, $maxhits, $numhits, $script) = @_;
my ($next_url, $max_page, $next_hit, $prev_hit, $left, $right, $upper, $lower, $first, $url, $last, $i);

# Return if there shouldn't be a speedbar.
return unless ($numhits > $maxhits);

# Strip nh=\d out of the query string, as we need to append it on. Try and keep
# the url looking nice (i.e. no double ;&, or extra ?.
$script =~ s/[&;]nh=\d+([&;]?)/$1/;
$script =~ s/\?nh=\d+[&;]?/\?/;
($script =~ /\?/) or ($script .= "?");
$script =~ s/&/&amp;/g;
$next_hit = $nh + 1;
$prev_hit = $nh - 1;
$maxhits ||= 25;
$max_page = int ($numhits / $maxhits) + (($numhits % $maxhits) ? 1 : 0);

# 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 ($url .= qq~<a href="$script;nh=1" class="spages">[&lt;&lt;]</a> ~);
($nh > 1) and ($url .= qq~<a href="$script;nh=$prev_hit" class="spages">[&lt;]</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="$script&amp;nh=$i" class="spages">$i</a> ~);
if ($i * $maxhits == $numhits) { $nh == $i and $next_hit = $i; last; }
}
$url .= qq~<a href="$script;nh=$next_hit" class="spages">[&gt;]</a> ~ unless ($next_hit == $nh or ($nh * $maxhits > $numhits));
$url .= qq~<a href="$script;nh=$max_page" class="spages">[&gt;&gt;]</a> ~ unless ($next_hit == $nh or ($nh * $maxhits > $numhits));
return $url;
}
and it still doesn't work Crazy

If you love cats - visit www.TheCatSite.com

Visit my LinkSQL based Cat Site - www.Meowhoo.com
Quote Reply
Re: [Anat] Changing the design of <%span%> In reply to
It must work with my code ... (At least it should)

Post your URL or PM me and I'll take a look ...

... or post this code + CSS file here... (Attachment)
Quote Reply
Re: [Anat] Changing the design of <%span%> In reply to
Why don't you try the global that I posted under c). No messing with the code... Wink

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] Changing the design of <%span%> In reply to
Yes, yogi is right!Wink
Quote Reply
Re: [Payooo] Changing the design of <%span%> In reply to
he he Laugh I thought globals were too intimidating... but I guess it's not worse than messing around with the actual pm files Tongue

I did save the original files so I'm going to get then back online and try working with Ivans global. I'll let you know how it goes.

Thanks everyone!

If you love cats - visit www.TheCatSite.com

Visit my LinkSQL based Cat Site - www.Meowhoo.com
Quote Reply
Re: [Anat] Changing the design of <%span%> In reply to
Ok, sorry Ivan, but I think I need a "for dummies" version Blush

I called the global: my_next_span

and copied and pasted it into the templates globals so it looks like that:

Code:
sub {
my $next_span = shift;
$next_span =~ s,(href=".+?"),$1 class="spages",g;
return $next_span;
}


in the template I have this:

Code:
<!-- Next/Previous links if spanning pages. -->

<font color="#FFFFFF" face="verdana" size="2">Pages: <%my_next_span($next_span)%> </font></font><br>
<%endif%>
</td></tr>




<tr><td colspan=2 align="left" bgcolor="<%category_row_color%>">
<br>
<%body_font%><%links%></font><br><br>
</td></tr>

<%if next_span%>
<!-- Next/Previous links if spanning pages. -->
<tr>
<td align="right" bgcolor="<%header_color%>" colspan=2>
<%body_font%><small>Pages: <%my_next_span($next_span)%>



</small></font><br>
</td>
</tr>
<%endif%>


In the CSS it looks like this:

Code:
a.spages:link {color:"#FFFFFF"; font-family:"arial"; font-size:14px; }
a.spages:hover {color: "#FFFFCC"; font-family:"arial"; font-size:14px; }



and it still doesn't work Crazy

* the Build.pm and HTML.pm are back to the way they were by the way

If you love cats - visit www.TheCatSite.com

Visit my LinkSQL based Cat Site - www.Meowhoo.com
Quote Reply
Re: [Anat] Changing the design of <%span%> In reply to
I'm still looking for an answer... Crazy

Anyone?

If you love cats - visit www.TheCatSite.com

Visit my LinkSQL based Cat Site - www.Meowhoo.com
Quote Reply
Re: [Anat] Changing the design of <%span%> In reply to
Can you have a look at the html page produced by this template, and tell me what it says? That might help to track the problem.

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] Changing the design of <%span%> In reply to
<td align="right" bgcolor="#4B0082">&nbsp;
<!-- Next/Previous links if spanning pages. --> <font color="#FFFFFF" face="verdana" size="2">Pages: <a href="http://www.meowhoo.com/..._Carriers/index.html" class="spages">[<<]</a> <a href="http://www.meowhoo.com/..._Carriers/index.html" class="spages">1</a> 2 </font></font><br> </td></tr>

Thanks Ivan! Please feel free to use my login info if you like... Smile

If you love cats - visit www.TheCatSite.com

Visit my LinkSQL based Cat Site - www.Meowhoo.com
Quote Reply
Re: [Anat] Changing the design of <%span%> In reply to
Is the font size the problem? Or the colour?

The global does what it should do, name place a

class="spages"

in all the links. I'm not an expert with style sheets, but maybe the styles are wrong? I think you don't have to use quotes in the style sheets... Maybe it's also a problem that you have <font> tags, but also font styles....

Ivan
-----
Iyengar Yoga Resources / GT Plugins

Last edited by:

yogi: Aug 22, 2002, 1:32 PM
Quote Reply
Re: [yogi] Changing the design of <%span%> In reply to
sorry for being so daft - it was a problem with the CSS and I've fixed it. BlushBlushBlush

Ivan - thanks!

If you love cats - visit www.TheCatSite.com

Visit my LinkSQL based Cat Site - www.Meowhoo.com
Quote Reply
Re: [Anat] Changing the design of <%span%> In reply to
Nice.

I went to your admin area actually, but didn't dare changing the templates...

Ivan
-----
Iyengar Yoga Resources / GT Plugins