Show all categories and few discussions from each.

@since 2.0.0
@access public
555751
public function Discussions() {
      // Setup head
      $this->AddCssFile('vanilla.css');
      $this->Menu->HighlightRoute('/discussions');
      $this->AddJsFile('discussions.js');
      $Title = C('Garden.HomepageTitle');
      if ($Title)
         $this->Title($Title, '');
      else
         $this->Title(T('All Categories'));
      $this->Description(C('Garden.Description', NULL));
      Gdn_Theme::Section('CategoryDiscussionList');
      
      // 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 and discussions
      $this->DiscussionsPerCategory = C('Vanilla.Discussions.PerCategory', 5);
      $DiscussionModel = new DiscussionModel();
      $this->CategoryModel->Watching = !Gdn::Session()->GetPreference('ShowAllCategories');
      $this->CategoryData = $this->CategoryModel->GetFull();
      $this->SetData('Categories', $this->CategoryData);
      $this->CategoryDiscussionData = array();
      foreach ($this->CategoryData->Result() as $Category) {
         if ($Category->CategoryID > 0)
            $this->CategoryDiscussionData[$Category->CategoryID] = $DiscussionModel->Get(0, $this->DiscussionsPerCategory, array('d.CategoryID' => $Category->CategoryID, 'Announce' => 'all'));
      }
      
      // Add modules
      $this->AddModule('NewDiscussionModule');
      $this->AddModule('DiscussionFilterModule');
      $this->AddModule('CategoriesModule');
      $this->AddModule('BookmarkedModule');
      $this->AddModule($CategoryFollowToggleModule);
      
      // Set view and render
      $this->View = 'discussions';

      $this->CanonicalUrl(Url('/categories', TRUE));
      $Path = $this->FetchViewLocation('helper_functions', 'discussions', FALSE, FALSE);
      if ($Path)
         include_once $Path;
      $this->Render();
   }
773661
public function index()
    {
        //  Page data
        $this->data['page']->title = 'Blog &rsaquo; Tags';

        // --------------------------------------------------------------------------

        $data                  = array();
        $data['include_count'] = true;
        $data['where']         = array();
        $data['where'][]       = array('column' => 'blog_id', 'value' => $this->blog->id);

        $this->data['tags'] = $this->blog_tag_model->getAll(null, null, $data);

        // --------------------------------------------------------------------------

        Helper::loadView('index');
    }
562324
public function index()
    {
        //  Meta & Breadcrumbs
        $this->data['page']->title            = APP_NAME . ' Blog';
        $this->data['page']->seo->description = '';
        $this->data['page']->seo->keywords    = '';

        // --------------------------------------------------------------------------

        //  Handle pagination
        $page      = $this->uri->rsegment(3);
        $perPage  = appSetting('home_per_page', 'blog-' . $this->oBlog->id);
        $perPage  = $perPage ? $perPage : 10;

        $this->data['pagination']           = new stdClass();
        $this->data['pagination']->page     = $page;
        $this->data['pagination']->per_page = $perPage;

        // --------------------------------------------------------------------------

        //  Send any additional data
        $data                    = array();
        $data['include_body']    = !appSetting('use_excerpts', 'blog-' . $this->oBlog->id);
        $data['include_gallery'] = appSetting('home_show_gallery', 'blog-' . $this->oBlog->id);
        $data['sort']            = array('bp.published', 'desc');

        //  Only published items which are not schduled for the future
        $data['where']   = array();
        $data['where'][] = array('column' => 'blog_id',      'value' => $this->oBlog->id);
        $data['where'][] = array('column' => 'is_published', 'value' => true);
        $data['where'][] = array('column' => 'published <=', 'value' => 'NOW()', 'escape' => false);

        // --------------------------------------------------------------------------

        //  Load posts and count
        $this->data['posts'] = $this->blog_post_model->getAll($page, $perPage, $data);
        $this->data['pagination']->total = $this->blog_post_model->countAll($data);

        // --------------------------------------------------------------------------

        //  Widgets
        $this->fetchSidebarWidgets();

        // --------------------------------------------------------------------------

        $this->data['isIndex'] = true;

        // --------------------------------------------------------------------------

        //  Load views
        $oView = Factory::service('View');
        $oView->load('structure/header', $this->data);
        $this->loadView('browse', $this->data);
        $oView->load('structure/footer', $this->data);
    }
440120
public function listCategory($category_group_id)
    {
        $this->setCategoryGroup($category_group_id);
        $this->actionListCategory();

        $this->setTitleListCategory();
        $this->setBreadcrumbListCategory();
        $this->setFilterListCategory();
        $this->setPagerListCategory();

        $this->setData('categories', $this->getListCategory());
        $this->setData('category_group_id', $category_group_id);

        $this->outputListCategory();
    }
289526
public function index()
    {
        $categories = $this->category->all();

        $categoryStructure = $this->categoryRenderer->render($categories->nest());

        return view('product::admin.categories.index', compact('categories', 'categoryStructure'));
    }
1185052
protected function show_categories($ismycourse = false) {
        global $CFG, $DB;
        if ($ismycourse) {
            return $this->show_my_categories();
        }
        if ($this->showcategories === null) {
            $show = false;
            if ($this->page->context->contextlevel == CONTEXT_COURSECAT) {
                $show = true;
            } else if (!empty($CFG->navshowcategories) && $DB->count_records('course_categories') > 1) {
                $show = true;
            }
            $this->showcategories = $show;
        }
        return $this->showcategories;
    }
461101
function () {
  var cats = getCategories();
  for (var i in cats) {
    log.debug('\n\nTEST CATEGORY: ' + cats[i]);
    testCategory(cats[i]);
  }
}
990983
public function category(Category $category)
    {
        $this->category = $category;

        $this->category->categorise($this);
    }
278360
protected function render_category_list(): string
    {
        if (!\has_category('', $this->post->get())) {
            return '';
        }

        return '<span class="category-links"><span class="meta-title">'.
            \esc_html__('Categories:', 'grotto-wp-posts').
        '</span> <span itemprop="articleSection">'.
            \get_the_category_list(', ', '', $this->post->get()->ID).
        '</span></span>';
    }
423752
protected function JoinCategory(&$Comments) {
      $DiscussionIDs = array();
      
      foreach ($Comments as &$Comment)
         $DiscussionIDs[$Comment['DiscussionID']] = TRUE;
      $DiscussionIDs = array_keys($DiscussionIDs);
      
      $Discussions = Gdn::SQL()->Select('d.*')
         ->From('Discussion d')
         ->WhereIn('DiscussionID', $DiscussionIDs)
         ->Get()->Result(DATASET_TYPE_ARRAY);
      
      $DiscussionsByID = array();
      foreach ($Discussions as $Discussion)
         $DiscussionsByID[$Discussion['DiscussionID']] = $Discussion;
      unset($$Discussions);
      
      foreach ($Comments as &$Comment) {
         $Comment['Discussion'] = $DiscussionsByID[$Comment['DiscussionID']];
         $Comment['CategoryID'] = GetValueR('Discussion.CategoryID', $Comment);
      }
   }
363033
def show_all_categories(call=None):
    '''
    
    '''
    if call == 'action':
        raise SaltCloudSystemExit(
            'The show_all_categories function must be called with -f or --function.'
        )

    conn = get_conn(service='SoftLayer_Product_Package')
    categories = []

    for category in conn.getCategories(id=50):
        categories.append(category['categoryCode'])

    return {'category_codes': categories}
264691
public function show()
    {
        $keyword  = request('q');
        $articles = [];
        $limit    = abs(request('limit', config('site.limit', 10)));

        $max_limit = config('site.max_limit', 100);
        if ($limit > $max_limit) {
            $limit = $max_limit;
        }

        if ($keyword) {
            $articles = $this->engine->search($keyword, $limit);
            $articles->appends('q', $keyword);
            $articles->appends('limit', $limit);
        }

        return view('search.show', compact('articles', 'keyword'));
    }
683158
private void initializeCategoryViews() {
    preferencesFxModel.getFlatCategoriesLst().forEach(category -> {
      CategoryView categoryView = new CategoryView(preferencesFxModel, category);
      CategoryPresenter categoryPresenter = new CategoryPresenter(
          preferencesFxModel, category, categoryView, breadCrumbPresenter
      );
      categoryController.addView(category, categoryView, categoryPresenter);
    });
  }
974703
public function UpdateDiscussionCount($CategoryID, $Discussion = FALSE) {
      $DiscussionID = GetValue('DiscussionID', $Discussion, FALSE);
		if (strcasecmp($CategoryID, 'All') == 0) {
			$Exclude = (bool)Gdn::Config('Vanilla.Archive.Exclude');
			$ArchiveDate = Gdn::Config('Vanilla.Archive.Date');
			$Params = array();
			$Where = '';
			
			if($Exclude && $ArchiveDate) {
				$Where = 'where d.DateLastComment > :ArchiveDate';
				$Params[':ArchiveDate'] = $ArchiveDate;
			}
			
			// Update all categories.
			$Sql = "update :_Category c
            left join (
              select
                d.CategoryID,
                coalesce(count(d.DiscussionID), 0) as CountDiscussions,
                coalesce(sum(d.CountComments), 0) as CountComments
              from :_Discussion d
              $Where
              group by d.CategoryID
            ) d
              on c.CategoryID = d.CategoryID
            set 
               c.CountDiscussions = coalesce(d.CountDiscussions, 0),
               c.CountComments = coalesce(d.CountComments, 0)";
			$Sql = str_replace(':_', $this->Database->DatabasePrefix, $Sql);
			$this->Database->Query($Sql, $Params, 'DiscussionModel_UpdateDiscussionCount');
			
		} elseif (is_numeric($CategoryID)) {
         $this->SQL
            ->Select('d.DiscussionID', 'count', 'CountDiscussions')
            ->Select('d.CountComments', 'sum', 'CountComments')
            ->From('Discussion d')
            ->Where('d.CategoryID', $CategoryID);
         
			$this->AddArchiveWhere();
			
			$Data = $this->SQL->Get()->FirstRow();
         $CountDiscussions = (int)GetValue('CountDiscussions', $Data, 0);
         $CountComments = (int)GetValue('CountComments', $Data, 0);
         
         $CacheAmendment = array(
            'CountDiscussions'      => $CountDiscussions,
            'CountComments'         => $CountComments
         );
         
         if ($DiscussionID) {
            $CacheAmendment = array_merge($CacheAmendment, array(
               'LastDiscussionID'   => $DiscussionID,
               'LastCommentID'      => NULL,
               'LastDateInserted'   => GetValue('DateInserted', $Discussion)
            ));
         }
         
         $CategoryModel = new CategoryModel();
         $CategoryModel->SetField($CategoryID, $CacheAmendment);
         $CategoryModel->SetRecentPost($CategoryID);
      }
   }
1097112
private function createCategory()
    {
        if($this->option('categories') || $this->option('categories_per_post_type') || $this->option('all')) {
            $this->comment('Creating dummy categories...');

            $output = (new \CategorySeeder())
                ->setCommand($this)
                ->run(
                    ($this->getDefaultOption('categories_per_post_type') ? $this->getDefaultOption('categories_per_post_type') : $this->getDefaultOption('categories')),
                    $this->getDefaultOption('post_type'),
                    ($this->getDefaultOption('categories_per_post_type') ? true : false)
                );

            $this->info($output);
        }
        return $this;
    }
3746
protected function loadCategories()
    {
        $categories = BlogCategory::with('posts_count')->getNested();
        if (!$this->property('displayEmpty')) {
            $iterator = function ($categories) use (&$iterator) {
                return $categories->reject(function ($category) use (&$iterator) {
                    if ($category->getNestedPostCount() == 0) {
                        return true;
                    }
                    if ($category->children) {
                        $category->children = $iterator($category->children);
                    }
                    return false;
                });
            };
            $categories = $iterator($categories);
        }

        /*
         * Add a "url" helper attribute for linking to each category
         */
        return $this->linkCategories($categories);
    }
371387
public function index()
    {
        $this->loadModel('Menu.Menus');
        $menus = $this->Menus->find()->all();

        $this->title(__d('menu', 'Menus List'));
        $this->set('menus', $menus);
        $this->Breadcrumb->push('/admin/menu/manage');
    }