@@ -34,7 +34,6 @@ class CategoriesController extends VanillaController {
34
34
const SORT_LAST_POST = 'new ' ;
35
35
const SORT_OLDEST_POST = 'old ' ;
36
36
37
- const ROOT_CATEGORY = ['Name ' => 'Roundtables ' , 'Url ' =>'/ ' ];
38
37
/**
39
38
* @var \Closure $categoriesCompatibilityCallback A backwards-compatible callback to get `$this->data('Categories')`.
40
39
*/
@@ -140,14 +139,8 @@ private function getCategoryTree($category = null, $displayAs = null, $recent =
140
139
$ perPage = c ('Vanilla.Categories.PerPage ' , 30 );
141
140
$ page = Gdn::request ()->get ('Page ' , Gdn::request ()->get ('page ' , null ));
142
141
list ($ offset , $ limit ) = offsetLimit ($ page , $ perPage );
143
-
144
- $ filter = [];
145
- if (Gdn::session ()->isValid ()) {
146
- $ filter ['UserID ' ] = Gdn::session ()->UserID ;
147
- $ filter ['isAdmin ' ] = Gdn::session ()->User ->Admin ;
148
- }
149
- $ categoryTree = $ this ->CategoryModel ->getTreeAsFlat ($ categoryIdentifier , $ offset , $ limit ,$ filter , 'c.DateInserted ' , 'desc ' );
150
- $ countOfCategoryTree = $ this ->CategoryModel ->countOfCategories ($ categoryIdentifier ,$ filter );
142
+ $ categoryTree = $ this ->CategoryModel ->getTreeAsFlat ($ categoryIdentifier , $ offset , $ limit ,null , 'c.DateInserted ' , 'desc ' );
143
+ $ countOfCategoryTree = $ this ->CategoryModel ->countOfCategories ($ categoryIdentifier , null );
151
144
$ this ->setData ('_Limit ' , $ perPage );
152
145
$ this ->setData ('_RecordCount ' , $ countOfCategoryTree );
153
146
$ this ->setData ('_CurrentRecords ' , count ($ categoryTree ));
@@ -341,11 +334,7 @@ public function index($categoryIdentifier = '', $page = '0') {
341
334
}
342
335
343
336
// Load the breadcrumbs.
344
-
345
- $ ancestors = CategoryModel::getAncestors (val ('CategoryID ' , $ category ));
346
- array_unshift ( $ ancestors , self ::ROOT_CATEGORY );
347
- $ this ->setData ('Breadcrumbs ' , $ ancestors );
348
-
337
+ $ this ->setData ('Breadcrumbs ' , $ this ->buildBreadcrumbs (val ('CategoryID ' , $ category )));
349
338
350
339
$ this ->setData ('Category ' , $ category , true );
351
340
// Set CategoryID
@@ -416,8 +405,10 @@ public function index($categoryIdentifier = '', $page = '0') {
416
405
$ this ->Head ->addRss (categoryUrl ($ category ) . '/feed.rss ' , $ this ->Head ->title ());
417
406
}
418
407
419
- // Add modules
420
- $ this ->addModule ('NewDiscussionModule ' );
408
+ if ($ category ->DisplayAs == 'Discussions ' ) {
409
+ // Add modules
410
+ $ this ->addModule ('NewDiscussionModule ' );
411
+ }
421
412
$ this ->addModule ('DiscussionFilterModule ' );
422
413
// $this->addModule('CategoriesModule');
423
414
$ this ->addModule ('BookmarkedModule ' );
@@ -557,10 +548,7 @@ public function all($Category = '', $displayAs = '') {
557
548
$ this ->description (c ('Garden.Description ' , null ));
558
549
}
559
550
560
- $ ancestors = CategoryModel::getAncestors (val ('CategoryID ' , $ this ->data ('Category ' )));
561
- array_unshift ( $ ancestors , self ::ROOT_CATEGORY );
562
- $ this ->setData ('Breadcrumbs ' , $ ancestors );
563
-
551
+ $ this ->setData ('Breadcrumbs ' , $ this ->buildBreadcrumbs (val ('CategoryID ' , $ this ->data ('Category ' ))));
564
552
565
553
// Set the category follow toggle before we load category data so that it affects the category query appropriately.
566
554
$ CategoryFollowToggleModule = new CategoryFollowToggleModule ($ this );
@@ -648,7 +636,7 @@ public function all($Category = '', $displayAs = '') {
648
636
$ this ->setData ('CategoryTree ' , $ categoryTree );
649
637
650
638
// Add modules
651
- if ($ Category ) {
639
+ if ($ Category && $ displayAs == ' Discussions ' ) {
652
640
$ this ->addModule ('NewDiscussionModule ' );
653
641
}
654
642
$ this ->addModule ('DiscussionFilterModule ' );
0 commit comments