本文整理汇总了PHP中CategoryModel::flattenTree方法的典型用法代码示例。如果您正苦于以下问题:PHP CategoryModel::flattenTree方法的具体用法?PHP CategoryModel::flattenTree怎么用?PHP CategoryModel::flattenTree使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CategoryModel
的用法示例。
在下文中一共展示了CategoryModel::flattenTree方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getData
/**
* Get the data for this module.
*/
protected function getData()
{
// Allow plugins to set different data.
$this->fireEvent('GetData');
if ($this->Data) {
return;
}
$categoryModel = new CategoryModel();
$Categories = $categoryModel->setJoinUserCategory(true)->getChildTree(null);
$Categories = CategoryModel::flattenTree($Categories);
$Categories2 = $Categories;
// Filter out the categories we aren't watching.
foreach ($Categories2 as $i => $Category) {
if (!$Category['PermsDiscussionsView'] || !$Category['Following']) {
unset($Categories[$i]);
}
}
$Data = new Gdn_DataSet($Categories, DATASET_TYPE_ARRAY);
$Data->datasetType(DATASET_TYPE_OBJECT);
$this->Data = $Data;
}
示例2: wrap
if (!defined('APPLICATION')) {
exit;
}
if (!function_exists('GetOptions')) {
include $this->fetchViewLocation('helper_functions', 'categories');
}
echo '<h1 class="H HomepageTitle">' . $this->data('Title') . '</h1>';
if ($Description = $this->Description()) {
echo wrap($Description, 'div', array('class' => 'P PageDescription'));
}
$this->fireEvent('AfterPageTitle');
$CatList = '';
$MaxDisplayDepth = c('Vanilla.Categories.MaxDisplayDepth') + $this->data('Category.Depth', 0);
$ChildCategories = '';
$CategoryTree = $this->data('CategoryTree');
$Categories = CategoryModel::flattenTree($CategoryTree);
$this->EventArguments['NumRows'] = $Categories;
echo '<ul class="DataList CategoryList">';
foreach ($Categories as $CategoryRow) {
$Category = (object) $CategoryRow;
$this->EventArguments['CatList'] =& $CatList;
$this->EventArguments['ChildCategories'] =& $ChildCategories;
$this->EventArguments['Category'] =& $Category;
$this->fireEvent('BeforeCategoryItem');
$CssClass = CssClass($CategoryRow);
$CategoryID = val('CategoryID', $Category);
if ($Category->CategoryID > 0) {
// If we are below the max depth, and there are some child categories
// in the $ChildCategories variable, do the replacement.
if ($Category->Depth < $MaxDisplayDepth && $ChildCategories != '') {
$CatList = str_replace('{ChildCategories}', '<span class="ChildCategories">' . Wrap(t('Child Categories:'), 'b') . ' ' . $ChildCategories . '</span>', $CatList);