Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Hiding categories and still keeping posting privelages
I was wondering if it is possible to hide certain categories without disallowing people to post in them. Since I am creating a forum for comments on certain anime reviews I don't want people to find the discussion pages by going on the forum part. I tried looking for an extension or an option with vanilla but i only found one that disallows certain groups to participate, which sounds to me like they wouldn't be able to post in that category.
0
This discussion has been closed.
Comments
...
I've got a hunch this might work for the discussions page (its untested):
function Category_HideFromDiscussions(&$SqlBuilder) { $SqlBuilder->AddWhere('c', 'CategoryID', '', '6', '<>', 'and', '', 0, 0); } $Context->AddToDelegate('SqlBuilder', 'PostGetDiscussionBuilder', 'Category_HideFromDiscussions');
where 6 is the category ID you want to block.
Unfortunately, there isin't a similar delegate (as of Vanilla 1.0.1) for the category manager, so until then you might have to paste that AddWhere line inside
\library\Vanilla\Vanilla.Class.CategoryManager.php
?>
then put it in a folder inside extensions and name it default.php.Oh, and make sure that there isn't any white space or extra lines outside the
<?php
and?>
, this can cause some hard-to-find validation errors.<?php /* Extension Name: Category Hider Extension Url: http://www.lussumo.com/addons Description: Hides certian categories from the discussion grid Version: 1.0 Author: WallPhone Author Url: http://wallphone.com/ */ // CONFIGURATION: Edit the two array() statements in the code to reflect the category IDs that should be blocked. // The code blocks categories 5 and 6, but if you wanted to instead block categories 1, 3, and 6, then use // array('1', '3', '6') in place of the other two array functions. if ( ('index.php' == $Context->SelfUrl) && !in_array(ForceIncomingString('CategoryID', ''), array('5', '6')) ) { function Category_HideFromDiscussions(&$DiscussionManager) { $SB = &$DiscussionManager->DelegateParameters['SqlBuilder']; foreach ( array('5', '6') as $CurrentBlock ) { $SB->AddWhere('t', 'CategoryID', '', $CurrentBlock, '<>', 'and', '', 0, 0); } } $Context->AddToDelegate('DiscussionManager', 'PostGetDiscussionBuilder', 'Category_HideFromDiscussions'); $Context->AddToDelegate('DiscussionManager', 'PreGetDiscussionCount', 'Category_HideFromDiscussions'); } ?>
Let me know if you have any other issues.
EDIT: Now fixed above.
All that is really left is the control panel for an admin to check/uncheck which categories they wish to hide (instead of forcing them to change those two
array()
functions)I will upload to the add-ons site when that control panel is built in.
I have a category called Archives and I am using this to hide archived discussions from the main discussions list and will hopefully be able to use CategoryRoles to prevent new discussions and comments being added. The purpose is for admins and moderators to move old discussions to the archive, maintaining them for reference only.
It's the equivalent of locking a category.
I hope to make this into an extension sometime...called Locked Categories or something.
if ($Context->SelfUrl == 'categories.php') { function VanillaGroups_HideCategory(&$CategoryManager) { $s = &$CategoryManager->DelegateParameters['SqlBuilder']; $s->AddWhere('t', 'CategoryID', '', {CategoryToBeHidden}, '!='); } $Context->AddToDelegate('CategoryManager', 'PostGetCategoryBuilder', 'HideCategory'); }
Copy the "AddWhere" line for each category to be hidden, or do another one of those "foreach" conditions Wallphone suggests.