Gossamer Forum
Home : Products : Gossamer Links : Discussions :

How would you do this?

Quote Reply
How would you do this?
Can anyone share their thoughts on how you'd go about the following...

When a user goes to add a link, I'd like to have some custom form fields added to the "add link" form dependant on the particular "category" they submitting their link into.

For example - if they're submitting a link into the "computers" category, I'd like to have additional fields related to computers - ram, harddrive size, etc. Or if they're in the "Books" category then the additional form fields might be isbn, author, publisher etc.

How would you approach it?

regan
Quote Reply
Re: [ryel01] How would you do this? In reply to
Hello Regan,

I have had similar setup before. There are multiple approach, however here is one option, that I think are pretty easy:

Specify Link Type: create a new field in category and also in link properties with options of your choice. (eg. computer, books, furniture) and setup different types of form for each option. Now using if/elseif function in add link page, serve the desired page.

The reason you create new field in link property, is because you also give each listing a link type and o while modifying the listing you can use the above trick to and make it work as desired. In addition, being able to separate them for search function can also be helpful.

Hope this helps.

Vishal

Vishal
-------------------------------------------------------
Quote Reply
Re: [SWDevil.Com] How would you do this? In reply to
Hi Vishal

How did you handle the processing of the new and varying form fields? ie. making some required input?

regan
Quote Reply
Re: [ryel01] How would you do this? In reply to
Normally even before working on the site, I prefer to open notepad and start writing all possible fields for each different category type without the worry or overwrite.

Then I sort them in the order that will allow me to manage the site in best and fastest manner. If you take the same road, many a time you will notice that there are certain fields that are not being used for one type and being used for other type & vice versa. In this case, I use the same field for different purpose for different category. However, if this seems complicated, then by all means one should just setup separate set of link properties as desired.

So while I will be setting up form for books category, I will be using ISBN and other related field options, and when I am setting up form for computer category, I will be using link properties created for computer category.

However when you are working with multiple type of categories and you should not use Not Null option, as suppose if you choose ISBN as required field, then users wanting to submit link in computer category would never be successful. If you want to setup required field, then you might want to think of using some javascript code on page for this purpose.

I hope this helps.

Vishal

Vishal
-------------------------------------------------------
Quote Reply
Re: [ryel01] How would you do this? In reply to
Hi,

Just to add a few comments. I took a similar path to the one explained by Vishal in the browser.cgi script, adding a link for each different type of link and harcoding several required values as hidden input fields.

I have one include file that includes common fields to all types (this is included in all files but I only need to modify it once to update all types) and then a specific include file for the link type.

I thought I should mention that in my case the hardest part was then to create a modify form that would pull the same include file as above that is specific to the link type and would do so using an <%if link_type eq '2'%><include include_linktype2.html%><elsif article_type eq '3'%> etc.

It is a pretty complicated task to allow for a link to be changed from one article type to another since the process really requires in the above situation for the user to first indicate a change in the link_type and then refresh the page to get the appropriate fields to display.

I have also managed the above situation with one modify form that displays fields depending on the link_type so that also requires the person to save the link_type and then modify again to fill in the new link_type fields

I hope this is not too badly explained as I'm pretty tired and hoping to be spleeping in a few minutes ;)

John
Significant Media