drop down list

7 posts by 3 authors in: Forums > CMS Builder
Last Post: May 21, 2012   (RSS)

By Joef5 - May 17, 2012

I have a products section where I can add product name, product id, description, price, shipping, etc. Some products are identical except for one feature - such as flavor or size.
How can I create a drop down list specific to each product, so that on the public pages, the viewer sees the list of options?
So for a product like milk shakes - the options would be vanilla, chocolate, strawberry, but for a product like Tee Shirts, the option might be for red, blue, green? Very few of the products would have the same list of options.

Re: [Joef5] drop down list

By Jason - May 18, 2012

Hi,

To do this, for any given product, you would need to know which field contains it's list of options. You could have a drop down called "optionsField" where you would select from a list of different field names. You could then use that value to select option values for that product.

For example:

<select name = "option">
<?php foreach ($record[$record['optionField'].":values"] as $value): ?>
<option value = "<?php echo $value;?>"><?php echo $value;?></option>
<?php endforeach ?>
</select>


In this example, we assume a few things:
1) optionField has a value that is the name of another field in your record
2) that other field is a multi value list (drop down or checkboxes)

Hope this helps get you started
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Joef5] drop down list

By robin - May 18, 2012

Hey Joe,

You can setup a multi value list in the section editor. For your "options" field - go into the modify popup and choose the " checkboxes (multi value)" option under "Display As".

That will make change the list options to be checkboxes in the product editor and you can choose which options will be available for each product.

Hope that helps,
Robin
Robin
Programmer
interactivetools.com

Re: [robin] drop down list

By Joef5 - May 18, 2012

Thanks Robin,

So doing as you said, then going into the product editor, the check boxes are there, displays the information, checked the boxes - but no show on the public display pages.

If I include <?php echo $record['options'] ?> it will output all the items that are checked in the product editor.

It appears this section of code is not returning any values or records.

<select name = "options">
<?php foreach ($record[$record['options'].":values"] as $value): ?>
<option value = "<?php echo $value;?>"><?php echo $value;?></option>
<?php endforeach ?>
</select>

--
Any thoughts on why it is not displaying the records?

Thanks,

Joe

Re: [Joef5] drop down list

By robin - May 21, 2012

Hey Joe,

A little fix to your foreach loop will probably help:

<?php foreach ($record['options:values'] as $value): ?>

If you ever want to see the structure of the data in $record - you can use a line like this:
<?php showme($record); ?>

Hope that helps,
Robin
Robin
Programmer
interactivetools.com

Re: [robin] drop down list

By Joef5 - May 21, 2012

Thanks Robin,

That Works!