TheBigK
Well-known member
I'm scratching my head over this for long time now and there doesn't seem to be a straightforward solution. My $viewParams pass on $forums array; which has the rows fetched from xf_node table. In my template, I want to show a drop-down that lists the categories and forums as follows -
Category 1
--Forum1
--Forum2
Category2
--Forum3
--Forum4
I'm planning to use <optgroup> to display the output; but the loop I'm trying to write in my template isn't very straightforward.
My best attempt so far is this: -
But that obviously is wrong because it shows the output as follows -
Would really appreciate some help fixing my loop.
Category 1
--Forum1
--Forum2
Category2
--Forum3
--Forum4
I'm planning to use <optgroup> to display the output; but the loop I'm trying to write in my template isn't very straightforward.
My best attempt so far is this: -
PHP:
<select name="node_id" class="textCtrl">
<xen:foreach loop="$forums" value="$forum">
<xen:if is="{$forum.node_type_id} == 'Category'">
<optgroup label="{$forum.title}">
</xen:if>
<option value="{$forum.node_id}">{$forum.title}</option>
</optgroup>
</xen:foreach>
</select>
But that obviously is wrong because it shows the output as follows -
Would really appreciate some help fixing my loop.