function writeCategoryTable($categories, $depth = 1, $inTable = false) { foreach ($categories as $category) { $displayAs = val('DisplayAs', $category); $urlCode = $category['UrlCode']; $class = val('CssClass', $category); $name = htmlspecialchars($category['Name']); if ($displayAs === 'Heading') { if ($inTable) { echo '</tbody></table></div>'; $inTable = false; } ?> <div id="CategoryGroup-<?php echo $urlCode; ?> " class="CategoryGroup <?php echo $class; ?> "> <h2 class="H"><?php echo $name; ?> </h2> <?php writeCategoryTable($category['Children'], $depth + 1, $inTable); ?> </div> <?php } else { if (!$inTable) { ?> <div class="DataTableWrap"> <table class="DataTable CategoryTable"> <thead> <?php writeTableHead(); ?> </thead> <tbody> <?php $inTable = true; } writeTableRow($category, $depth); } } if ($inTable) { echo '</tbody></table></div>'; } }
<?php if (!defined('APPLICATION')) { exit; } ?> <h1 class="H HomepageTitle"><?php echo $this->data('Title'); ?> </h1> <div class="P PageDescription"><?php echo $this->description(); ?> </div> <?php $this->fireEvent('AfterDescription'); $this->fireEvent('AfterPageTitle'); $categories = $this->data('CategoryTree'); writeCategoryTable($categories, 1); ?> <div class="PageControls Bottom"> <?php PagerModule::write(); ?> </div>
<input name="CategoryID" type="hidden" value="<?php echo htmlspecialchars($this->data('ParentCategory.CategoryID')); ?> " /> <input name="Limit" type="hidden" value="<?php echo $this->getLimit(); ?> " /> </div> <div class="FlatCategoryResult"> <?php if ($this->data('Layout') === 'table') { ?> <?php writeCategoryTable($this->data('Categories', []), 1); ?> <?php } else { ?> <ul class="DataList CategoryList"> <?php foreach ($this->data('Categories') as $category) { writeListItem($category); } ?> </ul> <?php } ?>
<?php if (!defined('APPLICATION')) { exit; } // This view is deprecated as of 2016-09-30. deprecated('vanilla/categories/subtree view'); if (isset($this->CategoryModel) && $this->CategoryModel instanceof CategoryModel) { $childCategories = $this->data('CategoryTree', []); $this->CategoryModel->joinRecent($childCategories); if ($childCategories) { include $this->fetchViewLocation('helper_functions', 'categories', 'vanilla'); if (c('Vanilla.Categories.Layout') === 'table') { writeCategoryTable($childCategories); } else { writeCategoryList($childCategories); } } }