Gossamer Forum
Home : Products : Links 2.0 : Customization :

Hop to dropdown

(Page 1 of 2)
> >
Quote Reply
Hop to dropdown
I made a hop to box for links categories that works and looks like the ubb hop to box. Saw a links1 version in the resource center and thought I'd make one
at the bottom of site_html_templates.pl just before the 1; ADD
Code:
#################################
sub hopto_category {
#################################
$output = qq~<script>
<!--
function taking()
{
location=
document.take.take2.options[document.take.take2.selectedIndex].value
}
//-->
</script>~;

$output .= qq(<form name="take"><b><font size="2">Hop to: </font></b><select name="take2">
<option selected value="">Select a Category</option>
<option value="">-------------------------------</option> );

CATEGORY: foreach $cat (sort keys %category) {
next CATEGORY if ($cat =~ /^\s*$/); # How'd that get in here? =)

$title = &build_unlinked_title ($cat);
@categorylist = split (/\//, $cat);

$output .= qq~<option value="$build_root_url/$cat/">$title</option>~;
}

$output .= qq~</select><input type="button" value="Go!" name="B1" onClick="taking()"></form>~;

return $output;
}
#########################################

then add hopto => &hopto_category,to the template load for the approriate page like the example below

Code:
sub site_html_home {
# --------------------------------------------------------
# This routine will build a home page. It is not meant to have any
# links on it, only subcategories.

return &load_template ('home.html', {
category => $category,
hopto => &hopto_category,
grand_total => $grand_total,
astlink => $lastlink,
%globals
});
}

then in your templete put <%hopto%> where you want the box to appear. I put it on the home.html and category.html. Hope you like it Smile

---------------------------
bartour.hypermart.net

[This message has been edited by Mutt (edited December 12, 1999).]
Quote Reply
Re: Hop to dropdown In reply to
Nice Mod.

Great job!

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
----------------------


Quote Reply
Re: Hop to dropdown In reply to
Greetings Mutt!

Thanks for the mod!

I carried all that was required. it builds the box ok but no categories inside! I put it on my home.html for the time being at the bottom.

------------------
www.nzcid.godzone.net.nz
New Zealand Christian Internet Directory




Quote Reply
Re: Hop to dropdown In reply to
I had this ame problem when i put hopto => &hopto_category, in the globals section. moving it to sub site_html_home fixed it. Did you follow these instruction exactly or is it slightly different? I've messed with my code so much that it's hard to remember what is orginal code and what is modded. maybe I need to include something else here but i don't see what.
Quote Reply
Re: Hop to dropdown In reply to
Hi there Mutt!

Teach me for being too clever. Smile Smile

Thats where I put it as well. Soon as I removed from globals it worked wonderfully well.

Thanks for a great mod..

------------------
www.nzcid.godzone.net.nz
New Zealand Christian Internet Directory




Quote Reply
Re: Hop to dropdown In reply to
Hi Mutt!

I spoke too soon. When I click go after choosing a category it comes up with "error on page"



------------------
www.nzcid.godzone.net.nz
New Zealand Christian Internet Directory




Quote Reply
Re: Hop to dropdown In reply to
ubb seems to have put a break in my code
should look like this

location=document.take. blahh blahh

see no break after =

if you went to edit my post and copied text from there, it would be fine

let me know.
your error is definatly in the javascript and its suppossed to be netscape and ie friendly.
Quote Reply
Re: Hop to dropdown In reply to
Hi Mutt!

Thank you for bearing with me. here is my whole code

Code:
#################################
sub hopto_category {
#################################
$output = qq~<script>
<!--
function taking()
{
location=document.take.take2.options[document.take.take2.selectedIndex].value
}
//-->
</script>~;
$output .= qq(<form name="take"><b><font face="Arial, Helevtica size="1">Hop to: </font></b><select name="take2">
<option selected value="">Select a Category</option>
<option value="">-------------------------------</option> );

CATEGORY: foreach $cat (sort keys %category) {
next CATEGORY if ($cat =~ /^\s*$/); # How'd that get in here? =)
$title = &build_unlinked_title ($cat);
@categorylist = split (/\//, $cat);
$output .= qq~<option value="$build_root_url/$cat/">$title</option>~;
}
$output .= qq~</select><input type="button" value="Go!" name="B1" onClick="taking()"></form>~;

return $output;
}
#########################################

I have checked and rechecked and it appears to be exactly the same with the alteration you told me to do.

Still comes up with "error on page"
Quote Reply
Re: Hop to dropdown In reply to
Hi Mutt!

To cover all my bases, I went into edit your orginal post of the code and copied that and pasted it into my site.template.html.pl.

Still the same error though Frown

------------------
www.nzcid.godzone.net.nz
New Zealand Christian Internet Directory




Quote Reply
Re: Hop to dropdown In reply to
I'll look at it when i get back from work.
Quote Reply
Re: Hop to dropdown In reply to
Hi Mutt!

Have it working. I tell you what I was doing for future reference. I put the code at the top of the page and also at the bottom of the index page.

It appears that you can only have it once on the page, otherwise it comes up with a page error. I took the bottom one off and it worked first time.

It is a great mod many thanks for it.



------------------
www.nzcid.godzone.net.nz
New Zealand Christian Internet Directory




Quote Reply
Re: Hop to dropdown In reply to
Hmmmm ... just thinking ....

how can I make it, so it will return the categories also for the nonenglish things AND like the following:

MainCategory_a
SubCategory_a1
SubCategory_a2
MainCategory_b
SubCategory_b1
SubCategory_b2

... meaning the MainCategory doesn't get shown with each entry?

Thanks
Thorsten
Quote Reply
Re: Hop to dropdown In reply to
I was trying to add this mod to the "add_success.html" so one can add another link quickly by selecting the menu (yes, mine is not a link directory and often people have a need to add more than one resource). The dropdown menu shows but the menu just does not list any categories.

It works fine if I put it on the home page. I did add hopto to my add-success routine in site-html. Any suggestions?

Thanks
Quote Reply
Re: Hop to dropdown In reply to
Why don't you use Loopy's Muliple (AltCategories) 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: Hop to dropdown In reply to
Hi Eliot,

Yes, I have the multiple category mod. But this for a new listing altogether. Of course, one can select an alternative category but if they want to submit another listing, then they do not have to go all the way back to the category page, in order to submit to a specific category (my categories are hard coded in the add form and one must add a listing only from a specific category).

Thanks
Quote Reply
Re: Hop to dropdown In reply to
 
Quote:
my categories are hard coded in the add form and one must add a listing only from a specific category).

Why do you have them hard coded in the add forms?? You can build a select list of categories or use the Category Select Mod to only show the categories you want.

I do not know how the Hopto option will help you.

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: Hop to dropdown In reply to
 
Quote:
build a select list of categories or

People are lazy. They don't pick the right categories while submitting and if I don't have it that way, then will add to the top category rather than the appropriate subcategory.

Quote:
I do not know how the Hopto option will help you.
Here is how: when one is done submitting a listing, they get the add_success page. In that page if I have the hopto menu, they can select another category, and it will be a bit easier for them rather than going back to the home page. However, they still might not select the proper category but it will be a bit easier.
Quote Reply
Re: Hop to dropdown In reply to
Well, this particular Mod only works on the home.html page...I tried to get it working on other template pages without much success.

And now, I do understand what you are looking for.

Best of luck!

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: Hop to dropdown In reply to
socrates,

I have temporary solution for you...it is not a drop-down menu, but it will print a list of your main categories...

1) Add the following sub-routine in your site_html_templates.pl file:

Code:
sub site_html_category_list {
#---------------------------------------------------------------------------
# List of Categories

my ($category) = @_;
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 (/\|/);
$category{$data[1]} = $data[1];
}
close (CAT);

foreach (sort keys %category) {
next unless ($_ =~ m,^([^/]*)$,);
if ($category ne $_) {
$suburl = "$build_root_url/" . &urlencode($_) . "/";
$output .= qq~<li><a href="$suburl">$_</li>\n~;
}
}
return $output;
}

These codes can be hacked into a drop-down menu by adding additional $output statements with select codes and redirect form codes.

2) Add the following global tag in the %globals section:

Code:
catlist => &site_html_category_list


3) In any of your template files, including your add_success.html, add the following tag:

Code:
<%catlist%>

Edit

Okay...I figured out how to create a drop-down menu. Although one glitch is that I am having problems getting the categories in the drop-down menu to be built clean with no underscores.

Anyway...here is what you do (similar to the instructions above)...

1) Download the redirect script from my site:

www.anthrotech.com/cgi/links/mods/redirect.txt

Upload this file to your links cgi directory. Change the permission of this file to 755.

2) Then add the following sub-routine in your site_html_templates.pl file:

Code:
sub site_html_category_redirect {
#---------------------------------------------------------------------------
# List of Categories

my ($category) = @_;
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 (/\|/);
$category{$data[1]} = $data[1];
}
close (CAT);

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

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

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

return $output;
}

3) Add the following tag definition in the %globals section in the site_html_templates.pl file:

Code:
redirect => &site_html_category_redirect

4) Then in your template files, like in your add_success.html file, add the following tag:

Code:
<%redirect%>

Hope this helps.

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.




[This message has been edited by AnthroRules (edited April 30, 2000).]

[This message has been edited by AnthroRules (edited April 30, 2000).]
Quote Reply
Re: Hop to dropdown In reply to
Hi !!!

How can I make changes in this mod to display only the subcategories instead categories ???

eg. Category: Sports

subcategories drop-down:

=> Baseball
=> Soccer
=> Football



Any ideas ??? Crazy


Regards,

marcoBR


Quote Reply
Re: Hop to dropdown In reply to
Change that one line (next unless) in the sub to this:

next unless ($_ =~ m,.*/([^/]+)$,); #this will show only subcategoires


Quote Reply
Re: Hop to dropdown In reply to
Thanks socrates...

... but where can I get the redirect.cgi ??? the url above is broken... Frown

Regards,

marcoBR

Quote Reply
Re: Hop to dropdown In reply to
See the thread at http://gossamer-threads.com/p/92875

I hope this helps

- Bobsie
bobsie@orphanage.com
http://goodstuff.orphanage.com/
Quote Reply
Re: Hop to dropdown In reply to
Hi!!!

I have a field called category_titlein the category.def and I want to show this name instead categegory_name for select options, thus:

=>Baseball
=>Soccer
=>Football

Instead->

=>Sports/Baseball
=>Sports/Soccer
=>Sports/Football


I tried the code below and I receive correct url values but blank select options ...


sub site_html_drop_category {
#---------------------------------------------------------------------------
# List of Categories
my ($category) = @_;
my ($suburl, $output, $category_title);

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 (/\|/);
$category{$data[1]} = $data[1];
$category_title{$data[1]} = $data[8];
}
close (CAT);

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

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

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

return $output;
}



What can I do to get this ???

Any ideas ???


Regards,

marcoBR


Quote Reply
Re: Hop to dropdown In reply to
Hi again!!!

How can I make changes in this mod to display only the subcategories instead categories ???

eg. Category: Sports

subcategories drop-down:

=> Sports/Baseball
=> Sports/Soccer
=> Sports/Football

socrates tip:

Change that one line (next unless) in the sub to this:

next unless ($_ =~ m,.*/([^/]+)$,); #this will show only subcategoires

I tried to make thios changes, but I get a list of the all categories whith his subcategories.

eg. my drop-down

=> Food/Popcorn
=> Food/Beans
=> Sports/Baseball
=> Sports/Soccer
=> Sports/Football


Any ideas ???


Regards,

marcoBR



> >