CategoryModel::getRootDisplayAs PHP Method

getRootDisplayAs() public static method

Get the display type for the root category.
public static getRootDisplayAs ( ) : string
return string
    public static function getRootDisplayAs()
    {
        return c('Vanilla.RootCategory.DisplayAs', 'Categories');
    }

Usage Example

 /**
  * Manage the category hierarchy.
  *
  * @param string $parent The URL slug of a parent category if looking at a sub tree.
  */
 public function categories($parent = '')
 {
     $this->permission(['Garden.Community.Manage', 'Garden.Settings.Manage'], false);
     $this->setHighlightRoute('vanilla/settings/categories');
     // Make sure we are reading the categories from the database only.
     $collection = $this->CategoryModel->createCollection(Gdn::sql(), new Gdn_Dirtycache());
     $allowSorting = true;
     $usePagination = false;
     $perPage = 30;
     $page = Gdn::request()->get('Page', Gdn::request()->get('page', null));
     list($offset, $limit) = offsetLimit($page, $perPage);
     if (!empty($parent)) {
         $categoryRow = $collection->get((string) $parent);
         if (empty($categoryRow)) {
             throw notFoundException('Category');
         }
         $this->setData('Category', $categoryRow);
         $parentID = $categoryRow['CategoryID'];
         $parentDisplayAs = val('DisplayAs', $categoryRow);
     } else {
         $parentID = -1;
         $parentDisplayAs = CategoryModel::getRootDisplayAs();
     }
     if (in_array($parentDisplayAs, ['Flat'])) {
         $allowSorting = false;
         $usePagination = true;
     }
     if ($parentDisplayAs === 'Flat') {
         $categories = $this->CategoryModel->getTreeAsFlat($parentID, $offset, $limit);
     } else {
         $categories = $collection->getTree($parentID, ['maxdepth' => 10, 'collapsecategories' => true]);
     }
     $this->setData('ParentID', $parentID);
     $this->setData('Categories', $categories);
     $this->setData('_Limit', $perPage);
     $this->setData('_CurrentRecords', count($categories));
     if ($parentID > 0) {
         $ancestors = $collection->getAncestors($parentID, true);
         $this->setData('Ancestors', $ancestors);
     }
     $this->setData('AllowSorting', $allowSorting);
     $this->setData('UsePagination', $usePagination);
     $this->addDefinition('AllowSorting', $allowSorting);
     $this->addJsFile('category-settings.js');
     $this->addJsFile('manage-categories.js');
     $this->addJsFile('jquery.nestable.js');
     require_once $this->fetchViewLocation('category-settings-functions');
     $this->addAsset('Content', $this->fetchView('symbols'));
     $this->render();
 }
All Usage Examples Of CategoryModel::getRootDisplayAs