当前位置: 首页>>代码示例>>PHP>>正文


PHP CategoryModel::getRootDisplayAs方法代码示例

本文整理汇总了PHP中CategoryModel::getRootDisplayAs方法的典型用法代码示例。如果您正苦于以下问题:PHP CategoryModel::getRootDisplayAs方法的具体用法?PHP CategoryModel::getRootDisplayAs怎么用?PHP CategoryModel::getRootDisplayAs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CategoryModel的用法示例。


在下文中一共展示了CategoryModel::getRootDisplayAs方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: categories

 /**
  * 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();
 }
开发者ID:vanilla,项目名称:vanilla,代码行数:55,代码来源:class.vanillasettingscontroller.php

示例2: all

 /**
  * Show all (nested) categories.
  *
  * @param string $Category The url code of the parent category.
  * @param string $displayAs
  * @since 2.0.17
  * @access public
  */
 public function all($Category = '', $displayAs = '')
 {
     // Setup head.
     $this->Menu->highlightRoute('/discussions');
     if (!$this->title()) {
         $Title = c('Garden.HomepageTitle');
         if ($Title) {
             $this->title($Title, '');
         } else {
             $this->title(t('All Categories'));
         }
     }
     Gdn_Theme::section('CategoryList');
     if (!$Category) {
         $this->Description(c('Garden.Description', null));
     }
     $this->setData('Breadcrumbs', CategoryModel::GetAncestors(val('CategoryID', $this->data('Category'))));
     // Set the category follow toggle before we load category data so that it affects the category query appropriately.
     $CategoryFollowToggleModule = new CategoryFollowToggleModule($this);
     $CategoryFollowToggleModule->SetToggle();
     // Get category data
     $this->CategoryModel->Watching = !Gdn::session()->GetPreference('ShowAllCategories');
     if ($Category) {
         $this->setData('Category', CategoryModel::categories($Category));
         $this->categoriesCompatibilityCallback = function () use($Category) {
             $Subtree = CategoryModel::GetSubtree($Category, false);
             $CategoryIDs = array_column($Subtree, 'CategoryID');
             return $this->CategoryModel->GetFull($CategoryIDs)->resultArray();
         };
     } else {
         $this->categoriesCompatibilityCallback = function () {
             return $this->CategoryModel->GetFull()->resultArray();
         };
     }
     $this->setData('CategoryTree', $this->getCategoryTree($Category ?: -1, $Category ? null : CategoryModel::getRootDisplayAs(), true, true));
     // Add modules
     $this->addModule('NewDiscussionModule');
     $this->addModule('DiscussionFilterModule');
     $this->addModule('BookmarkedModule');
     $this->addModule($CategoryFollowToggleModule);
     $this->canonicalUrl(url('/categories', true));
     if ($this->View === 'all' && $displayAs === 'Flat') {
         $this->View = 'flat_all';
     }
     $Location = $this->fetchViewLocation('helper_functions', 'categories', false, false);
     if ($Location) {
         include_once $Location;
     }
     $this->render();
 }
开发者ID:vanilla,项目名称:vanilla,代码行数:58,代码来源:class.categoriescontroller.php


注:本文中的CategoryModel::getRootDisplayAs方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。