Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Forcing users to choose a category
whu606
MVP
My original question was answered most helpfully by Lincoln here:
http://vanillaforums.org/discussion/16672/can-i-force-users-to-choose-a-category-in-vanilla-2#Item_6
but this fix no longer works with the latest version of Vanilla.
echo $this->Form->CategoryDropDown('CategoryID', array('Value' => GetValue('CategoryID', $this->Category)));
Lincoln's fix meant that users had to explicitly choose a category, and was very helpful for our site.
Could someone tell me how to alter the new code (assuming it is possible).
Cheers as always to anyone who can help.
http://vanillaforums.org/discussion/16672/can-i-force-users-to-choose-a-category-in-vanilla-2#Item_6
but this fix no longer works with the latest version of Vanilla.
In /views/post/discussion.php (copy it from Vanilla app into your theme if you haven't yet) find this:The new line is slightly different:echo $this->Form->DropDown('CategoryID', $this->CategoryData, array('TextField' => 'Name', 'ValueField' => 'CategoryID'));And replace with:echo $this->Form->DropDown('CategoryID', $this->CategoryData, array('IncludeNull' => TRUE, 'TextField' => 'Name', 'ValueField' => 'CategoryID'));
echo $this->Form->CategoryDropDown('CategoryID', array('Value' => GetValue('CategoryID', $this->Category)));
Lincoln's fix meant that users had to explicitly choose a category, and was very helpful for our site.
Could someone tell me how to alter the new code (assuming it is possible).
Cheers as always to anyone who can help.
Tagged:
0
Answers
thanks for your quick reply.
I edited the line to the one you suggested, but it doesn't seem to have any effect.
Previously, the category box was empty, and the user couldn't post until they had explicitly chosen a category.
Thanks.
No worries.
It was useful because it stopped users leaving the category on the default one.
They'll just have to get used to changing it!
Thanks.
Update, in case this gets found by a search in the future...
Just discovered that the code Todd supplied works provided that the Categories option is NOT set to 'Display root categories as headings.'