Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Multiple Add Form For Multiple Category

Quote Reply
Multiple Add Form For Multiple Category
Hello all,

At last i bought links sql and it looking great but i have a lot to study as long within this 2 years i only playing with links 2.0.

Well now i have a question to ask:

Is it possible to make a different add form for every category like i done before followed the thread at http://www.gossamer-threads.com/...forum.cgi?post=43893

Please help and thanks so much.
Quote Reply
Re: [reenee] Multiple Add Form For Multiple Category In reply to
Hi,

This may give you some tips, very similiar to what you want to do:

http://www.gossamer-threads.com/...orum.cgi?post=171454

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] Multiple Add Form For Multiple Category In reply to
Hi Alex, Thanks for reply,

I already read the thread and still blur how to make it for add form cause the thread is talk about search result and not the form custumization:

<%if query like 'automobiles'%>
<%include search_auto.html%>
<%elsif query like 'computers'%>
<%include search_computers.html%>
..
<%else%>
<%include search_default.html%>
<%endif%>

What i try to do is, when i click into the add link like http://www.worldbarterhouse.com/cgi-bin/add.cgi?ID=2, the add.html will include the form for that category, can u tell me how to do this please.

Please help and thank you so much.


Quote Reply
Re: [reenee] Multiple Add Form For Multiple Category In reply to
Ok....

The easiest way would be to make sure you have db_gen_category in the Admin set to ON. This will supress the category list, and force people to first move to the category they want to enter into.

This will also allow a tag ID that is equal to the category ID.

And, then do something like:

<%if ID%>
<%include ID.html%>
<%endif%>

Which... of course doesn't work :) Neither does $ID.html. include is parsing the end as a literal no matter what.

So, the next best thing is to create a global (or function) that takes ID and returns the HTML in a tag to be included in the template. This is sort of an indirect way of doing it, so before I spend time on it, I'll wait to see what Alex has to say about it.

The advantage of using a global, or function, would be that you have much more flexibility in determining what is included, how and when.




PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] Multiple Add Form For Multiple Category In reply to
Hi Pugdog,

Thanks for your help, its work, what i try to do is as below, at add.html file i add:

<%if ID=1%>
<%include add_announ.html%>
<%endif%>
<%if ID=2%>
<%include add_auto.html%>
<%endif%>
<%if ID=3%>
<%include add_buss.html%>
<%endif%>
<%if ID=4%>
<%include add_collect.html%>
<%endif%>
<%if ID=5%>
<%include add_computer.html%>
<%endif%>
<%if ID=6%>
<%include add_employ.html%>
<%endif%>
<%if ID=7%>
<%include add_general.html%>
<%endif%>
<%if ID=8%>
<%include add_lost.html%>
<%endif%>
<%if ID=9%>
<%include add_personal.html%>
<%endif%>
<%if ID=10%>
<%include add_services.html%>
<%endif%>
<%if ID=11%>
<%include add_real.html%>
<%endif%>
<%if ID=12%>
<%include add_rental.html%>
<%endif%>

<%ifnot ID%>
<%include include_form.html%>
<%endif%>

Please correct me if i'm wrong, so far the code is work to me, but i'm still thinking, how about the sub-categories or if i have more than 500 categories, i think there was a solution how to make it easier rather than i list down all the ID, for example Automobile/Car, how to make the 'Car' sub-category still use the same form for Automobile? Sorry to my english and please help.

Thanks.


Quote Reply
Re: [reenee] Multiple Add Form For Multiple Category In reply to
Hi,

This is why I said wait for Alex to answer :)


The solution should be something similar to my TopKeywords update, where you would include a function:

<%Links::User::include Category%>

Which would send <%Category%> to the function, which would return a tag that contained the HTML to insert,
such as <%add_category_fields%>

This would be either a self-containd <FORM> tag, or probably more safely, a list of text and <input> fields be
included into the general <form> tag.

Of course the easiest way would be for Alex to allow variable substituion in the <%include%> tag, which is why
I suggest waiting for him to jump in here.




PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [reenee] Multiple Add Form For Multiple Category In reply to
Hi,

Well, you are probably going to need to use a global. Something like:

custom_form =>
Code:
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';
}
open (FILE, "/path/to/admin/templates/default/$file");
read (FILE, my $data, -s FH);
close FILE;
return $data;
}

What that does is looks up the Full Name of the category, and then picks an html page to return. You would save that in your globals and then just add <%custom_form%> to your add.html template.

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] Multiple Add Form For Multiple Category In reply to
Alex,

Wouldn't it be better to use something where the Category ID was passed to the routine, and the routine first checked to see if a template existed, otherwise, use the default?

That way, you could override specific categories, but not others. The CategoryID is unique, while the name isn't.


Ooops, didn't finish. This would be of most benefit on large sites, where putting in dozens or thousands of names is not possible. Also, CatID won't change, but the category name could.

My problem with this is passing in the parameter ie: CatID to the routines, to make sure it comes back. GT::Template::Tags-> (or whatever) is probably the solution, but I just started to play with that, and haven't started thinking in those terms.




PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.

Last edited by:

pugdog: Jan 2, 2002, 10:21 AM
Quote Reply
Re: [pugdog] Multiple Add Form For Multiple Category In reply to
Hi Alex,

I got an error message with <%custom_form%> :

Code:
A fatal error has occured:

Unable to compile 'custom_form'. Reason: syntax error at (eval 8) line 42, near "}
.."
syntax error at (eval 8) line 46, near "}
open "
syntax error at (eval 8) line 50, near ";
}"

Please enable debugging in setup for more details.


Below is my code for 'custom_form':

Code:
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 =~ /^Announcements/) {
$file = 'add_announ.html';
}
elsif ($full_name =~ /^Automobiles/) {
$file = 'add_auto.html';
}
elsif ($full_name =~ /^Business_Opportunities/) {
$file = 'add_buss.html';
}
elsif ($full_name =~ /^Collectibles/) {
$file = 'add_collect.html';
}
elsif ($full_name =~ /^Computers___Software/) {
$file = 'add_computer.html';
}
elsif ($full_name =~ /^Employment/) {
$file = 'add_employ.html';
}
elsif ($full_name =~ /^General_Merchandise/) {
$file = 'add_general.html';
}
elsif ($full_name =~ /^Lost___Found/) {
$file = 'add_lost.html';
}
elsif ($full_name =~ /^Personals/) {
$file = 'add_personal.html';
}
elsif ($full_name =~ /^Professional_Services/) {
$file = 'add_services.html';
}
elsif ($full_name =~ /^Real_Estate/) {
$file = 'add_real.html';
}
elsif ($full_name =~ /^Rentals___Roommates/) {
$file = 'add_rental.html';
}
..
else {
$file = 'include_form.html';
}
open (FILE, "/home/worldbar/public_html/db/cgi-bin/admin/templates/default/$file");
read (FILE, my $data, -s FH);
close FILE;
return $data;
}

Please help and thank you so much.
Quote Reply
Re: [reenee] Multiple Add Form For Multiple Category In reply to
You don't want those

..

in there. =) Remove that line. As for using the name, this is so that all subcategories will inherit the form, not just a single category.

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] Multiple Add Form For Multiple Category In reply to
Thanks for you help Alex,

Yes, no more error, but the page does'nt include the file like 'add_auto.html' for 'Automobiles', the page only show:

Code:
Please completely fill out the form below, and we'll add your link as soon as possible.

(Add Link Button)

Please help.



Quote Reply
Re: [reenee] Multiple Add Form For Multiple Category In reply to
Hmm, can you change:

open (FILE, "/home/worldbar/public_html/db/cgi-bin/admin/templates/default/$file");

to:

open (FILE, "/home/worldbar/public_html/db/cgi-bin/admin/templates/default/$file") or return "Can't open: $file ($!)";

and see what happens?

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] Multiple Add Form For Multiple Category In reply to
Now with the message:

Code:
Please completely fill out the form below, and we'll add your link as soon as possible.

Can't open: add_announ.html (No such file or directory)
For your information, i already upload the file 'add_announ.html' at /templates/default/

Please Help.


Quote Reply
Re: [reenee] Multiple Add Form For Multiple Category In reply to
Oppss...sorry, I forgot to change to real path, The result is still blank, only show:

Code:
Please completely fill out the form below, and we'll add your link as soon as possible.

(Add Link)

Quote Reply
Re: [reenee] Multiple Add Form For Multiple Category In reply to
Oops, change

-s FH

to

-s FILE

sorry.

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] Multiple Add Form For Multiple Category In reply to
Yes, Its really Done.

Thanks Alex.
Quote Reply
Re: [reenee] Multiple Add Form For Multiple Category In reply to
Opss..before i forget, I think is still under the add form topic, Its regarding the 'Expirator Mod', I need an option to my user to choose how many days the clasiffied will show at the category, they're 15,30,45,60 days (scrool down box), at the end of period, the database will delete from database. Can this be make it with Links SQL ?

Please help and Thanks Again.


Last edited by:

reenee: Jan 3, 2002, 11:47 AM
Quote Reply
Re: [Alex] Multiple Add Form For Multiple Category In reply to
Ok,

I see the issue here :)

What was shown, in the example above, is not how to make each category have it's own form, but each MAIN category ie: each root-level category have it's own form for itself and it's progeny.

What I _heard_ was how to make _each_ category have it's own form, and that is somewhat more complex an issue than using whole root-trees :) If each of 35,000 categories could potentially have it's own add form, then using the name, rather than the number, would be a lot rougher.

Couldn't this be generalized further, so that what was passed in to the routine was the lowest modified sub-tree (such as with the default templates)??




PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] Multiple Add Form For Multiple Category In reply to
Hello all,

Back to the topic 'Multiple Add Form For Multiple Category', for sure, the global tag is working fine, but i just found the problem with cookies, simply i add the tag like <input name="Name" size=20 maxlength=20 value="<%Name%>"> at one of the form file for example add_auto.html, suppose on the text box will show the user's name on registration, but it only show <%Name%>. It was no problem if i add the tag at add.html and the name of user will show exactly what i need.

Please help.
Quote Reply
Re: [reenee] Multiple Add Form For Multiple Category In reply to
I followed everything you all mentioned in this thread; I was about to start asking about using multiple add forms when all of a sudden... Smile

So everything went fine, I now have a different add form per directory (or rather category) right under the root. All the different add forms come up right, but my first bug Frown came up when I tried as a regular user to add a link to one of the categories.

The error message is telling me to specify what category I want to put the link into.
Why?

How come now it has no idea of where to put the link and what do I need to do to get the menu with all the categories back?
What should I do so that the add.cgi script shows the category menus? (I have the <%category%> tag there already)

Thank you for your time.
Quote Reply
Re: [nt6] Multiple Add Form For Multiple Category In reply to
Hello all,

I was succesful using the tag of multiple form for multiple categories and its look great, but the problem now, how about to modify the link ? how to make the link recognise back which form are used. is it suppose i create the tag for multiple modify form for multiple categories ? Please help.