Gossamer Forum
Home : Products : Gossamer Links : Discussions :

custom field in the admin add/modify form

Quote Reply
custom field in the admin add/modify form
I'm in the strategy phase of this mod -- perhaps someone can give me some advice here.

I have a data base with many categories. People are allowed to post a link to multiple categories. I need a way to allow link owners to classify a link as a "featured" link in one or more of the categories that they put the link in.

For example: say a user adds a link in the following categories:

and they want to classify the link as featured on

but not

(or any combination there of).

The only way can think of doing this is to add a column to the links database called "featuredIn." Then create a custom select box global pulling from the category list that allows users to select the category(s) they want to "feature" the link in. (I can limit the categories they can select from using a AllowFeatured -yes/no select box in the category database).

The datafield featuredIn in the links db will consist of array of category ids.

Does this sound like a logical plan? Can you think of an easier method?

I think I can handle all of that for the public/User view...but where I get really stumped is how to implement this into the admin view. It seems the admin forms are built dynamically based on preset rules. Would it be possible to add a global into admin form to create a custom field as described above? This is where my brain hits the wall.

Any help or suggestions would be so awesome.

Many thanks,
Quote Reply
Re: [Swaylock] custom field in the admin add/modify form In reply to
Well.... the first thing I can say is "Good Luck" <G>

The next, is keep the rules of data normalization in mind. *DO* *NOT* add more than one bit of data to a field. In otherwords, if you want to feature the link in two categories, say 23 and 52, do *NOT* do something like create a field is_Featured_in and set it to "23 52" or "23|52". This was bad enough for flat file databases, but at least they were already parsing the text, but it's a flat-out no-no (pardon the pun) for a relational database.

Create a new table Featured_Links and set it up CatID/LinkID (look familiar?)

When you want to know if a link is featured in a category, you then just do a select * from Featured_Links where CatID=nnn

If you want to do subcategories, you can use the subcategory routines, and use a where clause - where CatID IN $list_of_IDs

Hope this helps :)

PUGDOG´┐Ż Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] custom field in the admin add/modify form In reply to

Thanks for the advice. I'm getting my head around it right now.
I'm sure to have some new questions.

Quote Reply
Re: [Swaylock] custom field in the admin add/modify form In reply to
uuhh. For example...after I set up the table, and put the form element in to include_form.html, how to I set things up to that the add.cgi will put the value in to the right table?