Reputation: 277
Evening all,
I have a Multi-Select custom field in my ExpressionEngine backend which I need to create a drop-down list from in my EE site. I can't think of a way but I'm sure it can't be too difficult. Can anyone explain how to do this please? (Preferably without the purchase of a plugin etc..)
Many thanks in advance
Upvotes: 2
Views: 5446
Reputation: 9116
What Multi-Select custom fieldtype and version of ExpressionEngine are you using?
If you're using FF Multi-select on EE1, this code will output all options from your multi-select custom field:
<select>
{exp:weblog:entries weblog="weblog_name" limit="1" dynamic="off"}
{custom_field_name:all_options}
<option value="{option_name}">{option}</option>
{/custom_field_name:all_options}
{/exp:weblog:entries}
</select>
If you only want to output the selected options in the multi-select custom field, this code will output them for you:
<select>
{exp:weblog:entries weblog="weblog_name" limit="1" dynamic="off"}
{custom_field_name}
<option value="{option_name}">{option}</option>
{/custom_field_name}
{/exp:weblog:entries}
</select>
If you're using EE2, the code will need to be updated since EllisLab renamed weblogs to channels and changed {option} and {option_name} to the combined variable {item}.
Upvotes: 0
Reputation: 9116
If you're using EE2 and the native Multi-Select Field custom channel field, this code will output all selected options from your multi-select custom field:
<select>
{exp:channel:entries channel="channel_name" limit="1" dynamic="off"}
{custom_field_name}
<option value="{item}">{item}</option>
{/custom_field_name}
{/exp:channel:entries}
</select>
The syntax for outputting the contents of a Multi-Select custom field in EE2 is slightly different from EE1. Instead of using {option}
to output the value, it's been replaced with {item}
.
Also of interest is that the native, "built-in" Multi-Select custom field in EE2 can't output an option and value separately.
You can use the P&T Field Pack to restore the EE1 FF Multi-select functionality where a Multi-Select custom field can have a value and an option.
Upvotes: 3
Reputation: 4564
Not even a $5 plugin?
http://devot-ee.com/add-ons/custom-drop-down/
Upvotes: 0