Gossamer Forum
Home : Products : Links 2.0 : Customization :

Improved Category Listing (Code Hack)

Quote Reply
Improved Category Listing (Code Hack)
Since people have had problems with the Hopto and other Category Listing Mods, I decided to clean up the codes and make it easier for people to install the following:

1) Print Category List -
http://www.anthrotech.com/cgi/links/faqs/catlist/

2) Drop-down menu of Main Categories -
http://www.anthrotech.com/...links/faqs/redirect/

Hope this helps.

I submitted these code hacks in the FAQ section of LINKS 2.0 tonight.

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
Anthro TECH, L.L.C
anthrotech.com
* Check Resource Center
* Search Forums
* Thinking out of the box (codes) is not only fun, but effective.


Quote Reply
Re: Improved Category Listing (Code Hack) In reply to
Great, works very nice. Also, thanks for replying to the other (original hopto) post yesterday. I was trying your solution, this afternoon and something else came up so left in between.

One question: is it possible to print the subcategories too, in the dropdown menu?

[This message has been edited by socrates (edited May 01, 2000).]
Quote Reply
Re: Improved Category Listing (Code Hack) In reply to
 
Code:
next unless ($_ =~ m,^([^/]*)$,);

Basically...these codes look for the main categories by ignoring the /, which signifies sub-categories. By deleting them, all the categories should appear, but don't quote me.

Wink

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
Anthro TECH, L.L.C
anthrotech.com
* Check Resource Center
* Search Forums
* Thinking out of the box (codes) is not only fun, but effective.


Quote Reply
Re: Improved Category Listing (Code Hack) In reply to
AnthroRules- Thanks for taking the time to clean these up and present them in a much easier and complete way, especially the layout of your instructions and the text file alternatives you've given (much easier to cut and paste)!

SteveK
Quote Reply
Re: Improved Category Listing (Code Hack) In reply to
You're welcome.

Glad to help.

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
Anthro TECH, L.L.C
anthrotech.com
* Check Resource Center
* Search Forums
* Thinking out of the box (codes) is not only fun, but effective.


Quote Reply
Re: Improved Category Listing (Code Hack) In reply to
Super thanks! These are nice features.
Quote Reply
Re: Improved Category Listing (Code Hack) In reply to
You're welcome.

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
Anthro TECH, L.L.C
anthrotech.com
* Check Resource Center
* Search Forums
* Thinking out of the box (codes) is not only fun, but effective.


Quote Reply
Re: Improved Category Listing (Code Hack) In reply to
Eliot,

thanx for the nice hack - any chance to use it with the non-english extension of links 2?

On the one hand I just don't like the underlines in the category-names and on the other hand i'd like to use the non-english names of my categories ...

Thanx for help!

Quote Reply
Re: Improved Category Listing (Code Hack) In reply to
 
Code:
$category{$data[1]} = $data[1];

to the number of your Non-English field in the category.def file.

Quote:
On the one hand I just don't like the underlines in the category-names and on the other hand i'd like to use the non-english names of my categories ...

Understandable...I am working on a method of producing a "clean" list of categories without the underscore character. With regards to using the non-english field, you may have to use the &urlencode to make the links to the non-english categories work...I don't know...because I do not use that Mod.

Regards,



------------------
Eliot Lee....
Former Handle: Eliot
Anthro TECH, L.L.C
anthrotech.com
* Check Resource Center
* Search Forums
* Thinking out of the box (codes) is not only fun, but effective.


Quote Reply
Re: Improved Category Listing (Code Hack) In reply to
If working with non-english categories, I have found, that it only works half way correctly, if you change the variables name in the subroutine: (Otherwise it messes up, with all category-listings on the homepage)

Code:
sub site_html_category_redirect {
#---------------------------------------------------------------------------
# List of Categories - Drop Down Menu
my ($kategory) = @_;
my ($suburl, $output);

open (CAT,"<$db_category_name") or &cgierr("error in numlinks. unable to open database:$db_category_name.\nReason: $!");
LINE: while(<CAT> ){
next LINE if (/^#/);
next LINE if (/^\s*$/);
@data=split (/\|/);
$kategory{$data[8]} = $data[8];
}
close (CAT);

$output .= qq~<form method="post" action="$db_cgi_url/redirect.cgi">\n~;
$output .= qq~<select class="hopto" name="goto" SIZE="1">\n~;

foreach (sort keys %kategory) {
next unless ($_ =~ m,^([^/]*)$,);
if ($kategory ne $_) {
$suburl = "$build_root_url/" . &urlencode($_) . "/";
$output .= qq~<option class="hopto" value="$suburl">$_</option>\n~;
}
}

$output .= qq~</select>\n~;
$output .= qq~<input type="submit" name="I1" value="Go!">\n~;
$output .= qq~</form>~;

return $output;
}

However, then it bring all (also subcategories) into the select field ...

Same (subdirectories) is with the category list subroutine . . .

Any ideas?



[This message has been edited by thoha (edited May 06, 2000).]
Quote Reply
Re: Improved Category Listing (Code Hack) In reply to
Well, you have removed the unless statement, which should NOT be removed if you only want to show Main categories from the Non-English Field.

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
Anthro TECH, L.L.C
anthrotech.com
* Check Resource Center
* Search Forums
* Thinking out of the box (codes) is not only fun, but effective.


Quote Reply
Re: Improved Category Listing (Code Hack) In reply to
Ehm, can you give me a hint, what I need to insert then?

Actually I do not know, what you mean :-/
Quote Reply
Re: Improved Category Listing (Code Hack) In reply to
Actually, you do have the next unless line of code...

Are there any special characters (like /) in the Non-English Field that separates between Categories and Sub-categories?

If not, guess what, you can only show all categories (including the sub-categories) in this particular modification.

Sorry...

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
Anthro TECH, L.L.C
anthrotech.com
* Check Resource Center
* Search Forums
* Thinking out of the box (codes) is not only fun, but effective.


Quote Reply
Re: Improved Category Listing (Code Hack) In reply to
The special character is \
Any idea?

Quote Reply
Re: Improved Category Listing (Code Hack) In reply to
I use Print Cat List mod, It works (show only main cat in nonenglish mode) when I paste the next unless statement before $category{$data[8]} = $data[8];

However, two problems still leave:
1. The cat are sorted by the nonenglish name ($data[8]) but I want they're sorted by english name ($data[1]) instead.

2. &urlencode($_) not point to correct url.

Need help ...............

Quote Reply
Re: Improved Category Listing (Code Hack) In reply to
I would have to work on this a bit...and I do not gaurantee I will come up with a solution.

The code hack was NOT written to work with other Mods, like the Non-English Mod.

Sorry.

Best of luck!

Regards,

Eliot Lee
Quote Reply
Re: Improved Category Listing (Code Hack) In reply to
Thank You -- Adam Hui Smile

Quote Reply
Re: Improved Category Listing (Code Hack) In reply to
Hello Guys !!!

Is it possible to list subcategories for a determinate category istead all ?

eg.

I want to put a drop down in my Sports category listing only his subcategories thus:

Category:
Sports

Drop Down:
Baseball
Soccer
Basketball
Football


Any ideas to make this ???


Regards,


marcoBR