Gossamer Forum
Quote Reply
need help
how to put link numbers in front of link listings?

I tried to look back at pugdog's codes given for links sql 1.11, but no luck.

maybe somebody can help?
Quote Reply
Re: [xpert] need help In reply to
Quote:
how to put link numbers in front of link listings?
What exactly do you mean? Try editing "subcategory.html", or "link.html".

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] need help In reply to
liek for example, the first link on list, and so on

1. link1

2. link2

3. link3

4. link4
Quote Reply
Re: [xpert] need help In reply to
So any idea Ivan?

here is the link to the old codes which don't work in newer versions by pugdog.http://www.gossamer-threads.com/...link%20number;#71605
Quote Reply
Re: [xpert] need help In reply to
Of course I have an idea.... try this global and call it on a template before <%loop links_loop%> (oh yes, this only works with loops):
Code:
sub {
my $tags = shift;
my $cp = ($tags->{title} =~ /^.*Page\s(\d*)/) ? $1 : 1;
my $ds = (($cp-1) * $CFG->{build_links_per_page}) + 1;
my $de = $CFG->{build_links_per_page} * $cp;
if ($tags->{total} < $de) {
$de = $tags->{total};
}
return { current_page => $cp,
display_start => $ds,
display_en => $ds };
}
In link.html, add somthing like near the top:
Code:
<%if display_start%>
<%set current_link_number = $display_start + $row_num - 1%>
<%endif%>
and where you want the number to appear, add
Code:
<%if current_link_number%><%current_link_number%><%endif%>
I haven't tested this (I use similar code, but it's all in a custom plugin, not in a global), but it should work.

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] need help In reply to
Hi Ivan,

I added the global and named it current_link_number,

Then added at top of link.html

<%if display_start%>
<%set current_link_number = $display_start + $row_num - 1%>
<%endif%>


then where i wanted link # to appear

<%if current_link_number%><%current_link_number%><%endif%>

then in category.html

<%loop links_loop%>

<%include link.html%>

<%endloop%>

but nothing comes up, any idea what i might be doign wrong?

Last edited by:

xpert: Sep 30, 2002, 6:25 AM
Quote Reply
Re: [xpert] need help In reply to
It should be

<%loop links_loop%>
<%include link.html%>
<%endloop%>

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] need help In reply to
Yeah i just changed that edit but your reponse beat me to it. however it still dun work after i change that!
Quote Reply
Re: [xpert] need help In reply to
Use <%GT::Template::dump%> to see what tags are available, and what their values are.

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] need help In reply to
current_link_number $VAR = 'CODE(0xafd2688)';

is available in category.html

and in link.html

current_link_number $VAR = 'CODE(0xb0b0690)';
current_page 1 display_en 1 display_start 1
Quote Reply
Re: [xpert] need help In reply to
Oh, you have to call the global something else than "current_link_number", maybe "get_link_numbers"

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] need help In reply to
Heh Ivan

Even after i changed the global name to get_link_numbers, it's still not displaying the numbers! Any further suggestion would be appreciated!
Quote Reply
Re: [xpert] need help In reply to
I'm not 100% sure but I don't think using + and - in a set tag is valid.

Last edited by:

Paul: Sep 30, 2002, 5:08 PM
Quote Reply
Re: [Paul] need help In reply to
So any suggestions how to make this work?
Quote Reply
Re: [xpert] need help In reply to
If you can't set the current link number in the template then you can use a global:

sub {
my $tags = shift;
my $row = $tags->{display_start}+$tags->{row_num}-1;
return $row;
}

Laura.
The UK High Street
Quote Reply
Re: [afinlr] need help In reply to
hey Laura,



I added your global except i remove the -1 to make the numbering start from 1, however right i now i encountered another problem, the numbering doesn't continue in span pages, it just started off new with 1-number per page again?

Code:
sub {
my $tags = shift;
my $row = $tags->{display_start}+$tags->{row_num};
return $row;
}
Quote Reply
Re: [xpert] need help In reply to
So close now... so any suggestions on how to make the numbering not reset when there's span pages?
Quote Reply
Re: [xpert] need help In reply to
Can you put

<%GT::Template::dump%>

on your category.html template, and tell me what the values are of

title
current_page
display_start
display_end

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] need help In reply to
title: the short name of category

there's no tags for

current_page
display_start
display_end

actually i deleted the global you provided before, and accomplished the numbering with the global provided by Luara, but however, like i said before the numbering resets in span pages!
Quote Reply
Re: [xpert] need help In reply to
The whole point of my global was that it works with span pages. Otherwise you don't need a global, you can just put

<%row_num%>

inside your link loop.....

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [xpert] need help In reply to
Sorry, I didn't make it clear - you do still need to use Ivan's global - mine just replaces the <%set ...%> tag.

Laura.
The UK High Street

Last edited by:

afinlr: Oct 2, 2002, 9:49 AM
Quote Reply
Re: [afinlr] need help In reply to
Heh,

I added Ivan's global and Laura's global, named Ivan's global get_link_numbers, and Laura's global set_link_number

and added the links loop in category.html and added

<%if display_start%>
<%set current_link_number = $set_link_number%>
<%endif%>

<%if current_link_number%><%current_link_number%><%endif%>

to link.html

however i still don't get the numbers to display!

here's the values offrom the gt dump of the category.html

get_link_numbers $VAR = 'CODE(0xb0edec0)';

set_link_number $VAR = 'CODE(0xb1b7d28)';
Quote Reply
Re: [xpert] need help In reply to
OK - once you have saved the two globals, all you need to do is:

1. At the top of your category.html template add the tag <%get_link_numbers%>

2. In your link.html template add <%set_link_number%> where you want the number to be.
I think that should work.Laura.
The UK High Street
Quote Reply
Re: [afinlr] need help In reply to
Yay, that works, thx Laura, and also Ivan!!