Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Add.cgi > How to load Sub-Category after selecting Category in first step!

Quote Reply
Add.cgi > How to load Sub-Category after selecting Category in first step!
Hello!

I have searched for this function or a global but did not find anything near to this. I find this extremely useful for many users including to myself.

What I would like to do is following:

Step one: User chooses a Category in step one, lets say Internet as a main category by a pop-up menu. This could be done by html codes instead of mysql queries. This category has the name "Cat" in the select option and value 100 which is the FatherID of Internet. User submits to the add.cgi.

Passing a variable from the form input to the add.cgi, basically.

Step two: A database query is made with the FatherID 100 and will give all the sub-categories as a drop down menu with select option. This is to be called by a tag <%subcategory%> in the include_form.html.

Making a query in the database with the input variable and creating a drop-down menu.

This global is very important when a user has large number of categories.

Following are some "near by" globals/ideas but not closer:

Possibility one:

<%if <%Cat%> eq '100'%>
<%include internet.txt%>
<%else%>
<%include remaining_cats.txt%>
<%endif%>

The Internet could have html codes to generate a drop-down menu for Internet category.

Possibility two:

By a global. Alex gave a solution as to how to make a query in the database and display a custom add.html. Here is a case where the variable is given and the query is done with this variable. Following is the solution by Alex:

custom_form => sub {
my $tags = shift;
my $query = $tags->{query};
my ($full_name) = $DB->table('Category')->select(['Full_Name'], { ID => $tags->{ID} })->fetchrow;
my $file = '';
if ($full_name =~ /^Automobiles/) {
$file = 'add_auto.html';
} elsif ($full_name =~ /^Announce/) {
$file = 'add_announce.html';
} else {
$file = 'include_form.html';
}

In this case above, one needs each seperate html pages. This is different to what I am looking for, however close to what it can help.

Would be nice if such a global of atleast a sub_routine is included in the main distribution, since it concerns to the main links scripts that would allow the pop-up menu in the add.cgi cut-down a lot. If there are 50 main categories and each having 20 sub-categories then the global will produce only 20 subcategories, as the main category is already selected. Hence there should be tags like <%category%> and <%subcategory%>, if the parameter of category is passed to a sub_routine.


Last edited by:

dearnet: Dec 15, 2002, 11:12 PM
Subject Author Views Date
Post Add.cgi > How to load Sub-Category after selecting Category in first step! dearnet 1172 Dec 15, 2002, 11:09 PM