Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

How to add number in front of links on LinkSQL 2.1.2?

(Page 2 of 2)
> >
Quote Reply
Re: [Doc_] How to add number in front of links on LinkSQL 2.1.2? In reply to
You can do something similar to above.

Create a global called 'calculate_category_offset'
Code:
sub {
my $title = shift;
my $nh = ($title =~ /Page\s(\d*)$/) ? $1 : 1;
return { category_offset => ($nh - 1) * $CFG->{build_links_per_page} };
}
In your category template, place the following code:
Code:
<%set category_page = 1%>
<%calculate_category_offset($title)%>
<%loop links_loop%>
<%include link.html%>
<%endloop%>
In the link.html template, put the following code:
Code:
<%if category_page%>
<%row_num + $category_offset%>.
<%endif%>

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] How to add number in front of links on LinkSQL 2.1.2? In reply to
Hi,Yogi!

I just did what you sugested and now links on category.html are showing numbered, the only problem is if i go to the next page (from page 1 to page 2),the links starts counting from 1 again it doesnt carry over the couting from one page to another.

is there a way to make it carry counting like on search_results.html?

Thanks again yogi.

Last edited by:

Doc_: Feb 5, 2003, 12:58 PM
Quote Reply
Re: [Doc_] How to add number in front of links on LinkSQL 2.1.2? In reply to
Can you put <%GT::Template::dump%> on the category.html template, go to the second page, and tell me what it says for 'title'?

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] How to add number in front of links on LinkSQL 2.1.2? In reply to
Can't you use the nh param instead of regexing the title?
Quote Reply
Re: [Paul] How to add number in front of links on LinkSQL 2.1.2? In reply to
That's what you would think, but there is no 'nh' tag on that page, you have to parse the 'title'. Let me know if you know a better way.Crazy

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] How to add number in front of links on LinkSQL 2.1.2? In reply to
Its not a tag - nh is an input parameter. It will be generated when you click the span bar. If it doesn't exist that means you are on page one.

my $nh = $IN->param('nh') || 1;
Quote Reply
Re: [yogi] How to add number in front of links on LinkSQL 2.1.2? In reply to
heres what i have for 'Title' on page two

Internet: Page 2




Quote Reply
Re: [Paul] How to add number in front of links on LinkSQL 2.1.2? In reply to
That's not true.

The links on the span bar point to

g=Category/Sub_Cat/more2.html;

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [Doc_] How to add number in front of links on LinkSQL 2.1.2? In reply to
Try changing:
Code:
my $nh = ($title =~ /Page\s(\d+)\s*$/) ? $1 : 1;

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] How to add number in front of links on LinkSQL 2.1.2? In reply to
My bad - I thought the category pages worked like search results.
Quote Reply
Re: [Paul] How to add number in front of links on LinkSQL 2.1.2? In reply to
I think the reason why they don't is that it works for both static and dynamic pages.

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] How to add number in front of links on LinkSQL 2.1.2? In reply to
still the same Yogi

on page2 it continue to count from 1 again
Quote Reply
Re: [Doc_] How to add number in front of links on LinkSQL 2.1.2? In reply to
I forgot to tell you that you need to use the global as

<%calculate_category_offset($title)%>

Maybe that's the problem?

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] How to add number in front of links on LinkSQL 2.1.2? In reply to
In Reply To:
I forgot to tell you that you need to use the global as

<%calculate_category_offset($title)%>

Maybe that's the problem?


I just changed the global from

calculate_category_offset

to

<%calculate_category_offset($title)%>


and still not working yogi

Last edited by:

Doc_: Feb 5, 2003, 2:20 PM
Quote Reply
Re: [Doc_] How to add number in front of links on LinkSQL 2.1.2? In reply to
In Reply To:
I have the LinkSQL 2.1.2 and i would like to add number in front of every link
Hmmm, I would just find the template file where the <UL> is specified for the list of links and change it to <OL>... UL is an Un-numbered List and OL is an Ordered List, i.e. numbered list Should take you about 2 minutes and not require you to change any Perl. If you change the Perl code, you create a mess for yourself when it is time to upgrade to the next version...
Quote Reply
Re: [yogi] How to add number in front of links on LinkSQL 2.1.2? In reply to
Hi-

I use the globals/mods that Yogi provided in this thread to number both my search results and the links on the category pages, and it has worked great.

But now I have a condition in my Links loop where it will omit any links that don't have the field Active set equal to 'Yes':

<%set category_page = 1%>
<%calculate_category_offset($title)%>
<%loop links_loop%>
<%if Active = 'Yes'%>
<%include link.html%>
<%endif%>
<%endloop%>


The problem is that if, for example, the second link has the field Active set equal to 'No', then it isn't included, and then the numbering gets thrown off. So, when the second link is omitted, the numbering of the link results looks like:

1. Link Title - Description
3. Link Title - Description
4. Link Title - Description
etc.


Does anyone know if there would be a way to keep the numbering in order even some links are omitted in the loop?

--Frank
Quote Reply
Re: [FrankM] How to add number in front of links on LinkSQL 2.1.2? In reply to
You can use the following as a quick and dirty hack:
Code:
<%set category_page = 1%>
<%calculate_category_offset($title)%>
<%loop links_loop%>
<%if Active = 'Yes'%>
<%include link.html%>
<%elsif%>
<%set category_offset -= 1%>

<%endif%>
<%endloop%>
This will work well on one page, but not across multiple pages, i.e. the offset on the second page will be wrong. If you wanted to solve this in a clean way you would need a plugin.

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] How to add number in front of links on LinkSQL 2.1.2? In reply to
Thanks Yogi,

I'll go with your quick fix now. I appreciate it.

--Frank
Quote Reply
Re: [Doc_] How to add number in front of links on LinkSQL 2.1.2? In reply to
For counting links on category pages
find that in build.pm

$display{total} = $numlinks = $catlink_db->hits;

And add this

##### offset #####
$display{offset} = $offset;

Now you have a tag nemd offset in yout category.html and link.html

Try now something like:
<%if search_page%><%row_num + $search_offset%>
<%else%><%row_num + $offset%>.<%endif%>
Quote Reply
Re: [Doc_] How to add number in front of links on LinkSQL 2.1.2? In reply to
For cool pages find in build.pm this one:

return Links::SiteHTML::display ('cool', { total => $total, grand_total => $GRAND_TOTAL, link_results => $output,
title => $title, title_linked => $title_l, percent => $percent, next_span => $toolbar,
link_results_loop => \@link_loop
});

and substitute it with:

my $offset = ($opts->{nh} - 1) * $opts->{mh};
return Links::SiteHTML::display ('cool', { total => $total, grand_total => $GRAND_TOTAL, link_results => $output,
title => $title, title_linked => $title_l, percent => $percent, next_span => $toolbar,
offset => $offset,
link_results_loop => \@link_loop
});
Quote Reply
Re: [Doc_] How to add number in front of links on LinkSQL 2.1.2? In reply to
Finally i do the new page, too. But with a real ugly php inside. ;-)
and only for not spanning pages.
Have someone done the count for the new page?
It seems there are al ot of things not be passed from the new.html to link.html

Another problem for me: I cant show the links with a loop.
Anyone a clue how to do that?

There is a tag named links, but i dont know how to pass it to the link.html
> >