0

I am using the following code within channel:form on EE 2.9

Categories: {category_menu} {select_options} {/category_menu}

The issue is that all my categories show up, I would like the limit it to one of my categories.

I have tried using category_group and category="5" but nothing worked.

thanks in advance

3
  • 1
    Can you post your entire template code? This will help us help you better :) Sep 23 '14 at 22:14
  • <div> {category_menu} <select name="category[]" id="categories" category="5" size="4" multiple="multiple"> {select_options} </select> {/category_menu} </div>
    – R Denney
    Sep 24 '14 at 23:26
  • It would be easier to read if you just update your answer:) Sep 25 '14 at 1:53
1

According to the documentation you should be able to set category="5" take a look at the bit about parameters.

Please update your question with your template code.

0

If you don't want people to be able to choose categories in your channel form, you can just use the category="y" parameter in your channel form tag as Mark said:

{exp:channel:form category="y"...}

But, if you do still want to show a select menu etc: It's not documented from what I can see, but you can use the show_group parameter within the categories tag (an alternative to the category_menu tag see https://ellislab.com/expressionengine/user-guide/add-ons/channel/channel_form/index.html#categories).

Then you could use a conditional within that to only output a certain category. Try the following code:

{categories show_group="x"}
{if '{category_id}' == y}
 <option value="{category_id}"{selected}>{category_name}</option>
{/if}
{/categories}

There may well be another parameter for the categories tag which just lets you limit to a particular ID directly without looping.

-1

Try this:

{category_menu}
<select name="category[]" size="10" multiple="multiple">
{exp:query sql="SELECT cat_name, cat_id FROM exp_categories WHERE group_id='5'"}
<option value='{cat_id}'>{cat_name}</option>
{/exp:query}
</select>
{/category_menu}

In the past, I've tried different versions of category_group=”#” or cat_id=”#” or category=”#”, but all versions returned all categories.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.