@@ -34,7 +34,6 @@ class CategoriesController extends VanillaController {
3434 const SORT_LAST_POST = 'new ' ;
3535 const SORT_OLDEST_POST = 'old ' ;
3636
37- const ROOT_CATEGORY = ['Name ' => 'Roundtables ' , 'Url ' =>'/ ' ];
3837 /**
3938 * @var \Closure $categoriesCompatibilityCallback A backwards-compatible callback to get `$this->data('Categories')`.
4039 */
@@ -140,14 +139,8 @@ private function getCategoryTree($category = null, $displayAs = null, $recent =
140139 $ perPage = c ('Vanilla.Categories.PerPage ' , 30 );
141140 $ page = Gdn::request ()->get ('Page ' , Gdn::request ()->get ('page ' , null ));
142141 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 );
151144 $ this ->setData ('_Limit ' , $ perPage );
152145 $ this ->setData ('_RecordCount ' , $ countOfCategoryTree );
153146 $ this ->setData ('_CurrentRecords ' , count ($ categoryTree ));
@@ -341,11 +334,7 @@ public function index($categoryIdentifier = '', $page = '0') {
341334 }
342335
343336 // 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 )));
349338
350339 $ this ->setData ('Category ' , $ category , true );
351340 // Set CategoryID
@@ -416,8 +405,10 @@ public function index($categoryIdentifier = '', $page = '0') {
416405 $ this ->Head ->addRss (categoryUrl ($ category ) . '/feed.rss ' , $ this ->Head ->title ());
417406 }
418407
419- // Add modules
420- $ this ->addModule ('NewDiscussionModule ' );
408+ if ($ category ->DisplayAs == 'Discussions ' ) {
409+ // Add modules
410+ $ this ->addModule ('NewDiscussionModule ' );
411+ }
421412 $ this ->addModule ('DiscussionFilterModule ' );
422413 // $this->addModule('CategoriesModule');
423414 $ this ->addModule ('BookmarkedModule ' );
@@ -557,10 +548,7 @@ public function all($Category = '', $displayAs = '') {
557548 $ this ->description (c ('Garden.Description ' , null ));
558549 }
559550
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 ' ))));
564552
565553 // Set the category follow toggle before we load category data so that it affects the category query appropriately.
566554 $ CategoryFollowToggleModule = new CategoryFollowToggleModule ($ this );
@@ -648,7 +636,7 @@ public function all($Category = '', $displayAs = '') {
648636 $ this ->setData ('CategoryTree ' , $ categoryTree );
649637
650638 // Add modules
651- if ($ Category ) {
639+ if ($ Category && $ displayAs == ' Discussions ' ) {
652640 $ this ->addModule ('NewDiscussionModule ' );
653641 }
654642 $ this ->addModule ('DiscussionFilterModule ' );
0 commit comments