Gossamer Forum
Home : Products : Links 2.0 : Customization :

Build Select Box Using links.db

Quote Reply
Build Select Box Using links.db
Hi

I would like to build a select box for a specific link using the values in that particular link's db field, and I would like to build that box within link.html.

For instance, let's say that I have a field called "Color" and I have 2 links - A and B. Link A has values in the db of Black, Gray, and White. Link B has values in the db of Blue, Green, and Red.

When the select boxes are built, Link A's select box would have:
Black
Gray
White

And, Link B's select box would have:
Blue
Green
Red

I had another thread going - http://www.gossamer-threads.com/...w=collapsed&sb=5, but I realized that I hadn't set up the issue correctly.

The purpose is the same as in the other thread, to integrate with a shopping cart, but the other thread dealt with using links.def to define the content of the select box.

What I'm after is to use the specific db values for a particular link as the values in that link's select box, all within link.html.

Does this sound do-able?

Thanks very much.
DT

Quote Reply
Re: Build Select Box Using links.db In reply to
I think it sounds doable, but I don't think you will be able to have Links auto-create the select lists for you because of the differences between the options in each link. There would be no way to define them in links.def since your select list would be variable. Select lists need a standard set of values in order for Links to create the list.

You could, possibly, add a field that would be similar in structure to the description field that you could use to include the select list code (the description field allows html code) that would then be displayed whereever you wanted it to be by using a tag in a template. That would probably be the easiest way to do it without needing to write a lot of extra code in the scripts to create the select list for that field. The only problem would be that you would have to include the select list code yourself for each record.

The only other alternative I can think of is creating a field that would contain a delimited list of the options and then, including perl code in a script that gets called when the order form is displayed to create a select list for that field based on the delimited list of options it contains.

I hope this helps.

- Bobsie
bobsie@orphanage.com
http://goodstuff.orphanage.com/
Quote Reply
Re: Build Select Box Using links.db In reply to
Thanks, Bobsie.

I just tried your suggestion - bull's-eye!

Code looks good, pages build, searches no problem.

Everything can be edited either through admin or a spreadsheet.

It looks like just what the doctor ordered. Thanks so much. Smile Smile

DT

Quote Reply
Re: Build Select Box Using links.db In reply to
The field to add the extra form code does have to be opened quite a bit and may max out the flat file system pretty fast, depending on how many items, etc., you've got. The better way, as you mentioned Bobsie, would be to have some script/code to do the building using only the values for a particular item. I wrote to Alex to suggest this for SQL and even 2.0 if it's do-able. This could be a neat and very flexible feature.

Many thanks for your help. Smile

DT