本文整理汇总了PHP中CategoryModel::GetSubtree方法的典型用法代码示例。如果您正苦于以下问题:PHP CategoryModel::GetSubtree方法的具体用法?PHP CategoryModel::GetSubtree怎么用?PHP CategoryModel::GetSubtree使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CategoryModel
的用法示例。
在下文中一共展示了CategoryModel::GetSubtree方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: discussions
/**
* Show all categories and few discussions from each.
*
* @param string $Category The url code of the parent category.
* @since 2.0.0
* @access public
*/
public function discussions($Category = '')
{
// Setup head
$this->addJsFile('discussions.js');
$this->Menu->highlightRoute('/discussions');
if (!$this->title()) {
$Title = c('Garden.HomepageTitle');
if ($Title) {
$this->title($Title, '');
} else {
$this->title(t('All Categories'));
}
}
if (!$Category) {
$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();
$this->CategoryModel->Watching = !Gdn::session()->GetPreference('ShowAllCategories');
if ($Category) {
$Subtree = CategoryModel::GetSubtree($Category, false);
$CategoryIDs = consolidateArrayValuesByKey($Subtree, 'CategoryID');
$Categories = $this->CategoryModel->GetFull($CategoryIDs)->resultArray();
} else {
$Categories = $this->CategoryModel->GetFull()->resultArray();
}
$this->setData('Categories', $Categories);
// Get category data and discussions
$this->DiscussionsPerCategory = c('Vanilla.Discussions.PerCategory', 5);
$DiscussionModel = new DiscussionModel();
$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;
}
// For GetOptions function
$Path2 = $this->fetchViewLocation('helper_functions', 'categories', false, false);
if ($Path2) {
include_once $Path2;
}
$this->render();
}
示例2: Index
/**
* Show all discussions in a particular category.
*
* @since 2.0.0
* @access public
*
* @param string $CategoryIdentifier Unique category slug or ID.
* @param int $Offset Number of discussions to skip.
*/
public function Index($CategoryIdentifier = '', $Page = '0')
{
if ($CategoryIdentifier == '') {
// Figure out which category layout to choose (Defined on "Homepage" settings page).
$Layout = C('Vanilla.Categories.Layout');
switch ($Layout) {
case 'mixed':
$this->View = 'discussions';
$this->Discussions();
break;
case 'table':
$this->Table();
break;
default:
$this->View = 'all';
$this->All();
break;
}
return;
} else {
Gdn_Theme::Section('DiscussionList');
// Figure out which discussions layout to choose (Defined on "Homepage" settings page).
$Layout = C('Vanilla.Discussions.Layout');
switch ($Layout) {
case 'table':
if ($this->SyndicationMethod == SYNDICATION_NONE) {
$this->View = 'table';
}
break;
default:
// $this->View = 'index';
break;
}
$Category = CategoryModel::Categories($CategoryIdentifier);
if (empty($Category)) {
if ($CategoryIdentifier) {
throw NotFoundException();
}
}
$Category = (object) $Category;
Gdn_Theme::Section($Category->CssClass);
// Load the breadcrumbs.
$this->SetData('Breadcrumbs', CategoryModel::GetAncestors(GetValue('CategoryID', $Category)));
$this->SetData('Category', $Category, TRUE);
// Load the subtree.
if (C('Vanilla.ExpandCategories')) {
$Categories = CategoryModel::GetSubtree($CategoryIdentifier);
} else {
$Categories = array($Category);
}
$this->SetData('Categories', $Categories);
// Setup head
$this->AddCssFile('vanilla.css');
$this->Menu->HighlightRoute('/discussions');
if ($this->Head) {
$this->AddJsFile('discussions.js');
$this->AddJsFile('bookmark.js');
$this->AddJsFile('options.js');
$this->Head->AddRss($this->SelfUrl . '/feed.rss', $this->Head->Title());
}
$this->Title(GetValue('Name', $Category, ''));
$this->Description(GetValue('Description', $Category), TRUE);
// Set CategoryID
$CategoryID = GetValue('CategoryID', $Category);
$this->SetData('CategoryID', $CategoryID, TRUE);
// Add modules
$this->AddModule('NewDiscussionModule');
$this->AddModule('DiscussionFilterModule');
$this->AddModule('CategoriesModule');
$this->AddModule('BookmarkedModule');
// Get a DiscussionModel
$DiscussionModel = new DiscussionModel();
$CategoryIDs = ConsolidateArrayValuesByKey($this->Data('Categories'), 'CategoryID');
$Wheres = array('d.CategoryID' => $CategoryIDs);
$this->SetData('_ShowCategoryLink', count($CategoryIDs) > 1);
// Check permission
$this->Permission('Vanilla.Discussions.View', TRUE, 'Category', GetValue('PermissionCategoryID', $Category));
// Set discussion meta data.
$this->EventArguments['PerPage'] = C('Vanilla.Discussions.PerPage', 30);
$this->FireEvent('BeforeGetDiscussions');
list($Offset, $Limit) = OffsetLimit($Page, $this->EventArguments['PerPage']);
if (!is_numeric($Offset) || $Offset < 0) {
$Offset = 0;
}
$CountDiscussions = $DiscussionModel->GetCount($Wheres);
$this->SetData('CountDiscussions', $CountDiscussions);
$this->SetData('_Limit', $Limit);
// We don't wan't child categories in announcements.
$Wheres['d.CategoryID'] = $CategoryID;
$AnnounceData = $Offset == 0 ? $DiscussionModel->GetAnnouncements($Wheres) : new Gdn_DataSet();
$this->SetData('AnnounceData', $AnnounceData, TRUE);
//.........这里部分代码省略.........
示例3: All
/**
* Show all (nested) categories.
*
* @since 2.0.17
* @access public
*/
public function All($Category = '')
{
// 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');
$this->Description(C('Garden.Description', NULL));
$this->SetData('Breadcrumbs', CategoryModel::GetAncestors(GetValue('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) {
$Subtree = CategoryModel::GetSubtree($Category);
$CategoryIDs = ConsolidateArrayValuesByKey($Subtree, 'CategoryID');
$Categories = $this->CategoryModel->GetFull($CategoryIDs)->ResultArray();
} else {
$Categories = $this->CategoryModel->GetFull()->ResultArray();
}
$this->SetData('Categories', $Categories);
// Add modules
$this->AddModule('NewDiscussionModule');
$this->AddModule('DiscussionFilterModule');
$this->AddModule('BookmarkedModule');
$this->AddModule($CategoryFollowToggleModule);
$this->CanonicalUrl(Url('/categories', TRUE));
$Location = $this->FetchViewLocation('helper_functions', 'categories', FALSE, FALSE);
if ($Location) {
include_once $Location;
}
$this->Render();
}