Gossamer Forum
Home : Products : Links 2.0 : Customization :

Mod for adding numbers next to links in...

(Page 1 of 2)
> >
Quote Reply
Mod for adding numbers next to links in...
i made a solution that will add numbers, like a numbered list in html next to each link in the search results, and it also works when the user goes on the next page. I'm not sure if i'll release yet, but want comments first.its at -
http://lookhard.hypermart.net/...search.cgi?query=web

Quote Reply
Re: Mod for adding numbers next to links in... In reply to
Looks great, Altavista style! Wink

Hope you are going to release that mod soon...

Quote Reply
Re: Mod for adding numbers next to links in... In reply to
Its good that mod BMXer, but surely you can do that by just adding $rec{'ID'} under

sub site_html_link {

in site_html.pl

eg.

output = qq~ $rec{'ID'} ~;

($output = qq~<ul><li><a class="link" href="$build_jump_url?$db_key=$rec{$db_key}">$rec{'Title'}</a>~);

if ($rec{'Description'}) { $output .= qq~ <span class="descript">- $rec{'Description'}</span>\n~; }
if ($rec{'isNew'} eq "Yes") { $output .= qq~ <img src="/img/new.gif">~; }
if ($rec{'isPopular'} eq "Yes") { $output .= qq~ <small><sup class="pop">pop</sup></small>~; }



NOT that im saying you mod is not good, because it is and I appreciate all of your hard work and you know more about Perl than I ever will!

Thanks

Thankyou
From Paul Wilson.
Quote Reply
Re: Mod for adding numbers next to links in... In reply to
I realise that if you do that, all of the number will be jumbled----you see that is why BMXer is clever and I am not--but it was nice to sound clever for 5 minutes!

Sorry

Thankyou
From Paul Wilson.
Quote Reply
Re: Mod for adding numbers next to links in... In reply to
how can you do it by just putting $rec{'ID'} when a search doesn't produce all the id's so they won't go in order like i have?
------------------------------------
ok, nevermind, i just read your edit
Quote Reply
Re: Mod for adding numbers next to links in... In reply to
Can you quickly tell me BMXer, how I can get search.cgi to search 2 links.db files?

Eg if someone searches, how can I get search.cgi to search links.db and links2.db together?

Thankyou
From Paul Wilson.
Quote Reply
Re: Mod for adding numbers next to links in... In reply to
ALSO.....

I run a music directory and wish to only allow people to add direct links to music files and so was wondering if someone could tell me how to allow people to only submit links that ended with .mp3 or .wav



Thankyou
From Paul Wilson.
Quote Reply
Re: Mod for adding numbers next to links in... In reply to
didn't you already post about this in your own post, why are you submitting this in mine?

Quote Reply
Re: Mod for adding numbers next to links in... In reply to
I know im sorry, but noone answered in my own post, so I thought Id have more chance of an answer if I asked you!

Thankyou,
From Paul Wilson.
Quote Reply
Re: Mod for adding numbers next to links in... In reply to
Great Mod. Can't Wait!

Regards,
Pagla

Quote Reply
Re: Mod for adding numbers next to links in... In reply to
Another bull's-eye, Bmxer!

Smile

Quote Reply
Re: Mod for adding numbers next to links in... In reply to
its more or less a code hack really, but i will release it as soon as i get back on my computer again to get code, and make instructions. Once again, windows has screwed, it says it can't load gd.exe or something and then asks me to restart

Quote Reply
Re: Mod for adding numbers next to links in... In reply to
ok here is the code hack, first in links.html put this

<%num_list%> >

before the font and the url is called.

Then in site_html_templates.pl in the sub site_html_search_results
add

num_list => $num_list,

to the list of template codes. Then in search.cgi
find these codes

Code:
# Go through each category of links returned, and build the HTML. Store in hash %link_output.
SETOFLINKS: foreach $setoflinks (sort keys %link_results) {
my $hits = ($#{$link_results{$setoflinks}} + 1) / ($#db_cols+1);
LINK: for ($i = 0; $i < $hits; $i++) {
$link_hits++;
if (($link_hits <= $highrange) && ($link_hits >= $lowrange)) {
%tmp = &array_to_hash ($i, @{$link_results{$setoflinks}});
$link_output{$setoflinks} .= &site_html_link (%tmp) . "\n";
}
}
}
and replace it with

Code:
if ($nh) {$addme = $maxhits * $nh;
}
$base = $addme;
$num_list = $base - $maxhits;
# Go through each category of links returned, and build the HTML. Store in hash %link_output.
SETOFLINKS: foreach $setoflinks (sort keys %link_results) {
my $hits = ($#{$link_results{$setoflinks}} + 1) / ($#db_cols+1);
LINK: for ($i = 0; $i < $hits; $i++) {
$link_hits++;
$tmp{'num_list'} = $num_list + 1;
if (($link_hits <= $highrange) && ($link_hits >= $lowrange)) {
%tmp = &array_to_hash ($i, @{$link_results{$setoflinks}});
$num_list= $num_list+1;
$tmp{'num_list'}= $num_list;
$link_output{$setoflinks} .= &site_html_link (%tmp) . "\n";
}
}
}
reply if any errors or any comments you have.


Quote Reply
Re: Mod for adding numbers next to links in... In reply to
Your hack works fine on search results. However, if you add the <%num_list%> tag in link.html, the category listings receive a unknown_tag error.

Quote Reply
Re: Mod for adding numbers next to links in... In reply to
oh, you know why, because i use a links.html for search and a seperate for categories.

in link.html try putting some kind of if around the <%num_list%> like
<%if query%>
<%num_list%>
<%endif%>

that way it will only show up in search. Unless people want it for categories too, and in that case, just use this for now.

Quote Reply
Re: Mod for adding numbers next to links in... In reply to
Well, I thought of trying to adapt your mod to the category listings as well, without acceptable results so far. I'd be glad, if you had suggestions for that.

Anyhow, thanks for that nice hack!

Quote Reply
Re: Mod for adding numbers next to links in... In reply to
Btw, if you do not have two different link.html, use the following if-statement for the num_list tag:
Code:
<%if num_list%>
<%num_list%>
<%endif%>
Quote Reply
Re: Mod for adding numbers next to links in... In reply to
Would it be possible to add numbers to cat... listing pages. Are you wokring on a MOD for this.

Quote Reply
Re: Mod for adding numbers next to links in... In reply to
why would you repost what i said, but change it around so it makes no sense? Why would you say if num_list when of course num_list will exist. It just doesn't exist in categories, so you should say query since query is only in the search. Ok, i wasn't planning on it, but i'll post a solution for the categories in a while.

Quote Reply
Re: Mod for adding numbers next to links in... In reply to
You said I should try putting <%if query%>. I tried and it didn't work. Then I tried <% if num_list%>, that worked. I'm not perl-savvy, just proceeded by trial and error, sorry. Thanks for your effort on the categories listing.

Quote Reply
Re: Mod for adding numbers next to links in... In reply to
ok, i did it for categories, but i'm not sure if it totally works, so i would need to test it on someone's computer, someone who has at least one category with over 20 links in it. See cuz the highest i have is 11, so i can see it change from 10 to 11 on the next page, but i don't know whats after that. If you agree, you can private message me login info by ftp

edited 8:42 pacific
nevermind, i just duplicated one link many times to get me 31 links, it works so far with build_links_per_page at 10, i'll test on others. It is modded in many places so i don't really wanna see alot of questions, i'll try and be specific when i post the code.
Quote Reply
Re: Mod for adding numbers next to links in... In reply to
Cool, this should be interesting.

Quote Reply
Re: Mod for adding numbers next to links in... In reply to
ok, for categories, just install the search.cgi method first, or if you don't want it, do all the steps except for editing search.cgi. Then open nph-build.cgi and

1 go down to the sub build_category_pages

2 there is 3 occurences of the following code
Code:

for ($i = 0; $i < $build_links_per_page; $i++) {
%tmp = &array_to_hash ($i, @{$links{$cat}});
$links .= &site_html_link (%tmp);

two like the above and the last one a bit different, like this
Code:
LINK: for ($i = 0; $i < $build_links_per_page; $i++) {
%tmp = &array_to_hash ($i, @{$links{$cat}});
last LINK if ($tmp{$db_key} eq "");
$links .= &site_html_link (%tmp);

3 Okay, first part of code to use, the very first site_html_link call that looks exactly like the first one i gave which is number 2, highlight that code, and paste this over it
Code:
if ($next_page) {$addme = $build_links_per_page * $page_num;
}
$base = $addme;
$num_list = $base;
if ($build_links_per_page == 9) {
$num_list = $num_list - 18;
}
if ($build_links_per_page == 8) {
$num_list = $num_list - 16;
}if ($build_links_per_page == 7) {
$num_list = $num_list - 14;
}if ($build_links_per_page == 6) {
$num_list = $num_list - 12;
}
if ($build_links_per_page == 5) {
$num_list = $num_list - 10;
}
if ($build_links_per_page == 4) {
$num_list = $num_list - 8;
}
if ($build_links_per_page == 3) {
$num_list = $num_list - 6;
}
if ($build_links_per_page == 2) {
$num_list = $num_list - 4;
}
if ($build_links_per_page == 1) {
$num_list = $num_list - 2;
}

for ($i = 0; $i < $build_links_per_page; $i++) {

%tmp = &array_to_hash ($i, @{$links{$cat}});
$tmp{'num_list'} = $num_list + 1;
$num_list= $num_list+1;
$tmp{'num_list'}= $num_list;
$links .= &site_html_link (%tmp);

4 Now for the second site_html_link reference(#2) which like number 3 is the exact code i listed above. Highlight it and paste this
Code:
if ($next_page) {$addme = $build_links_per_page * $page_num;
}
$base = $addme;
$num_list = $base;

for ($i = 0; $i < $numlinks; $i++) {

%tmp = &array_to_hash ($i, @{$links{$cat}});
$tmp{'num_list'} = $num_list + 1;
$num_list= $num_list+1;
$tmp{'num_list'}= $num_list;
$links .= &site_html_link (%tmp);

5 Now the very last call which looks like this
Code:
LINK: for ($i = 0; $i < $build_links_per_page; $i++) {
%tmp = &array_to_hash ($i, @{$links{$cat}});
last LINK if ($tmp{$db_key} eq "");
$links .= &site_html_link (%tmp);

should be higlighted and have this
pasted over it
Code:
if ($next_page) {$addme = $build_links_per_page * $page_num;
}
$base = $addme;
$num_list = $base - $build_links_per_page;

LINK: for ($i = 0; $i < $build_links_per_page; $i++) {
%tmp = &array_to_hash ($i, @{$links{$cat}});
$tmp{'num_list'} = $num_list + 1;
last LINK if ($tmp{$db_key} eq "");
$num_list= $num_list+1;
$tmp{'num_list'}= $num_list;
$links .= &site_html_link (%tmp);


INFO: Red code is what to paste, blue is what to paste over. Make sure you highlight exactly what i have said since foreach loops have brackets } at the end of them, make sure you don't copy the brackets because i know someone would come and say that i forgot a bracket when i didn't, i just didn't put it in to copy over or paste to.
Quote Reply
Re: Mod for adding numbers next to links in... In reply to
I have installed your MOD, everything works great except that i have 10 links on one page and when i click on the NEXT to go to the next set of links the number starts as -9 and not 11 as it should.
Quote Reply
Re: Mod for adding numbers next to links in... In reply to
I have installed your mod too. Unfortunately, the page counts are not consecutive, eg. one (sub)category starts with 21, the next with 141 etc. It works in each single page, but not in the categories/subcategories.

> >