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.
Can I set a default category for new discussions?
Right now the dropdown defaults to the first category it sees. Can I set this to another category?
Tagged:
0
Best Answers
-
hgtonight MVP
Just add a conditional.
public function PostController_BeforeFormInputs_Handler($Sender) { if(!$Sender->CategoryID) { $Sender->Category = CategoryModel::GetFullByUrlCode('category-slug'); } }
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.
5
Answers
The dropdown defaults to the category the New Discussion button was clicked in.
Do you want to change the order of the Dropdown list, or just select a different option by default?
Also, this is 2.0.18.8, right?
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.
2.0.18.8, yes. I was just hoping to set a default category when users select Start a New Discussion from the home page.
To your theme hooks!
Replace
category-slug
with the last part of the url of the category you want. E.g. if I wanted this page to be the default category to post into: http://localhost/vanilla/index.php?p=/categories/the-watercooler, I would put 'the-watercooler' in there.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.
BOOM. Excellence and help at its finest. Thank you.
Followup: is there any way to set this so it only does this on the home page and not within specific categories?
Just add a conditional.
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.
Is this also possible by using the CategoryID?
Found it:
$Sender->Category->CategoryID = ID_HERE;