PDA

View Full Version : Textarea in admincp to dropdown in template


AndrewSimm
11-27-2014, 07:36 PM
I have an option in the admin panel that uses a textarea to display a list of teams. I am trying to insert it into a drop down menu. Here is what I have. If I just put {vb:raw vboptions.cisteamlogo} into the template it list everything separated by a comma.

<select name="team_logo" class="primary" title="team_logo" tabindex="1" />{vb:raw vboptions.cisteamlogo}</select>

vBNinja
11-27-2014, 08:08 PM
first you're gonna need to explode the setting and register it to the template you're trying to use


$exploded_array = explode(',' $vbulletin->options['cisteamlogo']);
$templater = vB_Template::create('YOUR_TEMPLATE');
$templater->register('exploded_array', $exploded_array);


if the template you're using is a stock vb template, pre-register the variable in a plugin using the parse_templates hook

then in you're template you can do something like:


<select name="team_logo" class="primary" title="team_logo" tabindex="1" />
<vb:each from="exploded_array" value="option">
<option value="{vb:raw option}">{vb:raw option}</option>
</vb:each>
</select>