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.
Recreate/Override/Modify the Categories dropdown
davidnhutch
New
Hi,
I currently have these categories in the "Categories" dropdown when you create a new discussion:
Parent 1 Child A Child B Child C Parent 2 Child D Child E
(Note that "Parent 1" and "Parent 2" are not selectable because I chose the appropriate setting in Dashboard. Only the children are selectable.)
Now, I'm writing a plugin and would like to be able to programmatically show only:
Parent 1 Child A Child B Child C
...or...
Parent 2 Child D Child E
...depending on some logic.
So, should I attempt to recreate the Categories box from scratch? But then I'll get the look but not the actual action of it. Or, can I somehow override the Categories dropdown? Or just programmatically delete the entries I don't want?
Thanks mucho!
David
Tagged:
0
Comments
In order to do this with php I think you would have to write a plugin with a function
PostController_BeforeFormInputs_Handle ($Sender)
that sets$Sender->ShowCategorySelector = false
so that this code will not be executed:(see applications/vanilla/views/post/discussion.php)
Then you can echo this code by yourself but delete the options from the CategoryDropDown before you echo it.
Otherwise you can insert javascript to the page and delete the OPTIONs from the SELECT on client side.
How you do it depends on a) the criteria you base your decision on and b) if your user might in worst case (no js) see a categories.
If you don't want people posting in these categories, don't give the permission to post to the members. Vanilla only shows categories a user can post to. No coding necessary.
As an aside, be sure to test your settings out as a normal member of your site as the original account created with vanilla is a "superadmin" that always has all permissions. This is to prevent you from locking your admin account out of the system.
Search first
Check out the Documentation! We are always looking for new content and pull requests.
Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.
@hgtonight : Thanks for your thought, but the reason I want to do this is not to permanently disable certain users from posting in certain categories, but to do so on a transient basis - so it must be selected programmatically at page-load-time.
@R_J : Thanks! It works!!!!