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

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

(Page 1 of 2)
> >
Quote Reply
How to add number in front of links on LinkSQL 2.1.2?
Hi,Guys!

I have the LinkSQL 2.1.2

and i would like to add number in front of every link and ive been trying hard for almost 3 months now, and also been searching this forum for a long time,but im not able to get that done by myself, i think cause i have no idea about what files do i have to do the changes.

im kindda newbie on this so can someone be kind enough to help me out here please,can you provide a step by step instructions on how to get that done?

im trying hard but again this is totally over my head.

thanks guys.

Last edited by:

Doc_: Feb 3, 2003, 8:52 PM
Quote Reply
Re: [Doc_] How to add number in front of links on LinkSQL 2.1.2? In reply to
What do you mean? On search pages, on category pages? In the database?


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] How to add number in front of links on LinkSQL 2.1.2? In reply to
i mean to make the links on search results pages be numbered instead of the default "bullet"

like:

page 1

1- link and description

2- link and description

page 2

3- link and description

4- link and description

etc..


that way when a person do a search on my site the results would be displayed like altavista or msn,etc...

Thanks for taking the time to reply my message pugdog

Last edited by:

Doc_: Feb 4, 2003, 12:48 AM
Quote Reply
Re: [Doc_] How to add number in front of links on LinkSQL 2.1.2? In reply to
You'll need to do a bit of work on things.

Search no longer returns what page it was on in the search order. It returns <%span%>, or variations of it, <%next%> , <%next_span%>, etc, but not a tag with what page you are on. That is embedded in the routine that returns the globbed tag.

If you are using the <%loop%> to display results, you can add in

<%row_num%>

Which will give you the row in that loop, but it won't be passed along from page to page. Each page will start at 1 and end with maxhits.

There are a number of things that have been removed from Links, which really should not have been, and should be added back. This is one of them.

Because of the way things work, I do not think it will work to try to pass page back into the search routine. I think once it runs through the display process, extra tags are filtered out. But you could try. I was trying to pass category ID into the detail page, but it was being filtered.


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [Doc_] How to add number in front of links on LinkSQL 2.1.2? In reply to
In theory this is quite simple to do as the page parameter used to build the span bar is all you need.

page * links_per_page

...will give you the start point of your current page (assuming page is greater than one)...if the page is 1 then your start position is 1.

So you'd just need to hook into the build routine and add a new tag to the link loop, this is an example (without looking at the code)...

Code:
my $start_pos = $page > 1 ? (($page - 1) * $links_per_page) : 1;

while (my $link_rec = $sth->fetchrow_hashref) {
$link_rec->{custom_count} = $start_pos++;
push @links_loop, $link_rec;
}

Last edited by:

Paul: Feb 4, 2003, 8:53 AM
Quote Reply
Re: [Doc_] How to add number in front of links on LinkSQL 2.1.2? In reply to
I've posted a topic in that past in hopes of doing the same thing. I don't remember it getting much of a response. The fustrating part is I've seen numbering of LinksSQL search results and category ranking being done on another site. I just can't figure out how he did it. Besides the visual appeal I've built a cool feature I'd like to use but need to have that individual link numbering to make it work.

Anywayz if anyone has a clue on how to do this I'd love to here as well!

Later
Quote Reply
Re: [Paul] How to add number in front of links on LinkSQL 2.1.2? In reply to
The 'page' parameter is not passed in the templates any longer. Do a <%GT:Template:dump%> on search_results.html

You can't use a global, since that only has access to what the template parser has.

Therefore, without creating a "plugin" to "hook" into the routines, there is no way to access it short of code editing. If you are offering to write one, and post it here, I'm sure we'd all appreciate it.


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [Jonze] How to add number in front of links on LinkSQL 2.1.2? In reply to
Hi,

If you want to edit your code, it's fairly easy.

It's just not portable any more.

You'd need to do it for each upgrade in Links, and I've sort of made it a point not to encourage that sort of stuff, unless someone *really* wants it.

If you really want it, take paul's suggestion, and edit your code.

It won't do anything bad when you upgrade, you'll just lose your link numbering, and have to edit your code again.

It would be *really* nice if GT added this back in, and also added in CategoryID for people who reach links via browsing (ie: clicking a link from a Category page). They also "lost" the ability to do that somewhere around the change to 2.0, which made some advertising scripts stop working right, and makes picking the right banners for detail pages and such harder than it should be.


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [Jonze] How to add number in front of links on LinkSQL 2.1.2? In reply to
Hi again,

In ../Links/user/Search.pm

Find:

Code:
# Print the output.
my $results = {
link_results => $link_results,
link_results_loop => \@link_results_loop,
category_results => $category_results,
category_results_loop => \@category_results_loop,
link_hits => $link_count,
cat_hits => $cat_count,
next => $toolbar,
term => $term,
page => $args->{nh}
};
return $results;
}


and add the above line into it.

Now, you can create a global using paul's code, that takes tags->{page} and figures out what the start of the numbering should be.

<%set_start_num ('page')%>

That will call the global and return a tag, such as <%page_start%>

You can then in your template use:

<%row_num + page_start%>

and you will increment your count.

If you *really* need/want this, I will write it up.


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [Doc_] How to add number in front of links on LinkSQL 2.1.2? In reply to
First of all, you have to use the 'link_results_loop' and 'category_results_loop' tags as pugdog said. No need to edit your code, though....

Use this global (calculate_search_offset):
Code:
sub {
my $nh = shift;
my $mh = shift;
return {search_offset => 0 } unless $nh =~ /^\d+$/;
$mh ||= $CFG->{search_maxhits};
return { search_offset => ($nh - 1) * $mh };
}

Do something like the following in the search_results.html template:
Code:
<%set search_page = 1%>
<%calculate_search_offset($nh,$mh)%>
<%loop link_results_loop%>
<%include link.html%>
<%endloop%>

Finally, in link.html, put the following code wherever you want the number to appear:
Code:
<%if search_page%>
<%row_num + $search_offset%>.
<%endif%>

I just added this on my page, have a look at
http://www.iyengar-yoga.com/...earch.cgi?query=yoga

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

Last edited by:

yogi: Feb 4, 2003, 10:09 AM
Quote Reply
Re: [Paul] How to add number in front of links on LinkSQL 2.1.2? In reply to
In Reply To:
In theory this is quite simple to do as the page parameter used to build the span bar is all you need.

page * links_per_page

...will give you the start point of your current page (assuming page is greater than one)...if the page is 1 then your start position is 1.

So you'd just need to hook into the build routine and add a new tag to the link loop, this is an example (without looking at the code)...

Code:
my $start_pos = $page > 1 ? (($page - 1) * $links_per_page) : 1;

while (my $link_rec = $sth->fetchrow_hashref) {
$link_rec->{custom_count} = $start_pos++;
push @links_loop, $link_rec;
}


do you mind telling me in which file or where do i have to add or try your suggestion (code)?

Thanks for your reply i really appreciated.
Quote Reply
Re: [Doc_] How to add number in front of links on LinkSQL 2.1.2? In reply to
Hi,

I just got this working on my copy - it was the "nh" parameter I meant and not "page" - same difference. You can do it with a simple plugin without editing any core code but I'd suggest using Yogi's code.

Last edited by:

Paul: Feb 4, 2003, 9:26 AM
Quote Reply
Re: [pugdog] How to add number in front of links on LinkSQL 2.1.2? In reply to
In Reply To:

If you *really* need/want this, I will write it up.


I do really need that pugdog, and i need it badly, if you can write that up i appreciated.

Guys i just want to thank you all for the replys

its been very kind of you to take the time to help me here, thank you ,thank you thank you.
Quote Reply
Re: [Doc_] How to add number in front of links on LinkSQL 2.1.2? In reply to
I slighly changed the global in the previous post, it works now perfectly.

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
Man I love the community! Made a post then when to lunch, and a solution was found by the time I got back. Thanks a lot for looking into this guys. I'm sure many can use this on there site as well. Now I can add some java magic.

Great job working that out via global Yogi. Laugh Just what I was looking for!
Quote Reply
Re: [Jonze] How to add number in front of links on LinkSQL 2.1.2? In reply to
Hi

I just follow the instructions of pugdog and yogi and

now i have the search results numbered, but i must have done something wrong because the numbers are not carry over to next page when i go to next page it starts counting from 1 to 25 again and also the results are been displayed twice on same page like one list from 1 to 25 numbered and one whitout numbers but same results (same links)on same page.

also i got this error message

Error: Variable 'calculate_search_offset' is not a code reference

can tell me what am i doing wrong?

Thanks for the GREAT SUPPORT GUYS.

Last edited by:

Doc_: Feb 4, 2003, 10:37 AM
Quote Reply
Re: [Doc_] How to add number in front of links on LinkSQL 2.1.2? In reply to
Make sure that the first five characters of the global are exactly

sub {

i.e.

sub<space>{

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
heres the codes on my global

sub {
my $nh = shift;
my $mh = shift;
return {search_offset => 0 } unless $nh =~ /^\d+$/;
$mh ||= $CFG->{search_maxhits};
return { search_offset => ($nh - 1) * $mh };
}

P.s. i just did the copy and past from your post to my global file.

Sorry to ask that stupid guestion,but on my templates directory theres a globals.txt file do i have to add that code there or create a new global.txt on the templates directory?

again sorry for the guestion,but im seriously a total newbie on this.

Thanks again.

Last edited by:

Doc_: Feb 4, 2003, 10:58 AM
Quote Reply
Re: [Doc_] How to add number in front of links on LinkSQL 2.1.2? In reply to
You shouldn't touch the globals.txt file.

Go to 'Build -> Template Globals' and add the code there, with the proper name.

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
YOGI YOU ARE A GENIOUS

How can i thank you for such great support man

theres no words enough to express my gratitude.

i just wanna say thank you again to you and to PUGDOG Sly

..............................................................................

just a final question do you have any idea why the links are been repeated on the same page?

as i mentioned the results are showing first 25 links (numbereds now) and right below last numbered link (25) it starts showing all 25 links again but now without the numbers.

Thanks yogi.

Last edited by:

Doc_: Feb 4, 2003, 11:20 AM
Quote Reply
Re: [Doc_] How to add number in front of links on LinkSQL 2.1.2? In reply to
> YOGI YOU ARE A GENIOUS

Thanks.

You probably still have <%link_results%> somewhere on the search_results.html template.

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:
You probably still have <%link_results%> somewhere on the search_results.html template.


you're were right it was the <%link_results%> on the search_results.html that was repeating the links i just removed and now EVERYTHING WORKS PERFECTLY.

Yogi if wasnt for your help im sure i wouldnt have that done,and now not only me but the entire LinkSQL community can benefit from it, and have the numbered search results links added to theyr sites.

and for that as i said theres no words that can express our gratitude for what you just did yogi.

Thank you again for the great support yogi.

P.S. and i really meant, when i say that you are a GENIOUS, believe me you really are, keep it up man, god bless you.

Last edited by:

Doc_: Feb 4, 2003, 11:38 AM
Quote Reply
Re: [Doc_] How to add number in front of links on LinkSQL 2.1.2? In reply to
Just would like to mention, that link numbering will is also available as an optional feature in my under development Xtended Link Display (XLD) plugin.

You can find info about the planned plugin features in these threads:
- [PLUGIN] Xtended Link Display plugin development news
- Webmaster33's under development or planned plugins

The plugin release date is not known at the moment, but I think it's good to know, that there will be a plugin which will give you link numbering feature you wanted.

Best regards,
Webmaster33


Paid Support
from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...
Quote Reply
Re: [yogi] How to add number in front of links on LinkSQL 2.1.2? In reply to
>> No need to edit your code, though....


Then where are you getting the 'nh' parameter from?

In the code, it's sent to the toolbox routines, but it's stripped out before the rest of the tags are returned.

It doesn't show up in the <%GT::Tempalate::dump%> dump, so how you can use them as $mh,$nh in the templates.

I *know* it works, I want to know why. If it's not showing up in the tag dump, it may not work in a future revision. If you are relying on "$IN" that is a pretty risky thing to do.


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] How to add number in front of links on LinkSQL 2.1.2? In reply to
Hi,guys!

Just a question, i just noticed that the links listed on the category pages is not numbered as the search_results.html page so my question is, its possible to make the category.html links be numbered the same way as the search_results.html page?


does the yogi's solution apply to that too?

i tryed but only shows the number 0 (zero) in front of first link.


thanks again.

Last edited by:

Doc_: Feb 4, 2003, 4:22 PM
> >