Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] Display subcategories in blog layout only when user has access #18408

Merged
merged 3 commits into from
Oct 27, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 55 additions & 51 deletions components/com_content/views/category/tmpl/blog_children.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,69 +13,73 @@

$class = ' class="first"';
$lang = JFactory::getLanguage();
$user = JFactory::getUser();

if ($this->maxLevel != 0 && count($this->children[$this->category->id]) > 0) : ?>

<?php foreach ($this->children[$this->category->id] as $id => $child) : ?>
<?php
if ($this->params->get('show_empty_categories') || $child->numitems || count($child->getChildren())) :
if (!isset($this->children[$this->category->id][$id + 1])) :
$class = ' class="last"';
endif;
?>
<div<?php echo $class; ?>>
<?php $class = ''; ?>
<?php if ($lang->isRtl()) : ?>
<h3 class="page-header item-title">
<?php if ( $this->params->get('show_cat_num_articles', 1)) : ?>
<span class="badge badge-info tip hasTooltip" title="<?php echo JHtml::_('tooltipText', 'COM_CONTENT_NUM_ITEMS_TIP'); ?>">
<?php echo $child->getNumItems(true); ?>
</span>
<?php endif; ?>
<a href="<?php echo JRoute::_(ContentHelperRoute::getCategoryRoute($child->id)); ?>">
<?php echo $this->escape($child->title); ?></a>
<?php $groups = $user->getAuthorisedViewLevels(); ?>
Copy link
Contributor

@csthomas csthomas Oct 24, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better to put it higher up to line 17 or 19

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

<?php // Check whether category access level allows access to subcategories. ?>
<?php if (in_array($child->access, $groups)) : ?>
<?php if ($this->params->get('show_empty_categories') || $child->numitems || count($child->getChildren())) :
if (!isset($this->children[$this->category->id][$id + 1])) :
$class = ' class="last"';
endif;
?>
<div<?php echo $class; ?>>
<?php $class = ''; ?>
<?php if ($lang->isRtl()) : ?>
<h3 class="page-header item-title">
<?php if ( $this->params->get('show_cat_num_articles', 1)) : ?>
<span class="badge badge-info tip hasTooltip" title="<?php echo JHtml::_('tooltipText', 'COM_CONTENT_NUM_ITEMS_TIP'); ?>">
<?php echo $child->getNumItems(true); ?>
</span>
<?php endif; ?>
<a href="<?php echo JRoute::_(ContentHelperRoute::getCategoryRoute($child->id)); ?>">
<?php echo $this->escape($child->title); ?></a>

<?php if ($this->maxLevel > 1 && count($child->getChildren()) > 0) : ?>
<a href="#category-<?php echo $child->id; ?>" data-toggle="collapse" data-toggle="button" class="btn btn-mini pull-right"><span class="icon-plus"></span></a>
<?php if ($this->maxLevel > 1 && count($child->getChildren()) > 0) : ?>
<a href="#category-<?php echo $child->id; ?>" data-toggle="collapse" data-toggle="button" class="btn btn-mini pull-right"><span class="icon-plus"></span></a>
<?php endif; ?>
</h3>
<?php else : ?>
<h3 class="page-header item-title"><a href="<?php echo JRoute::_(ContentHelperRoute::getCategoryRoute($child->id)); ?>">
<?php echo $this->escape($child->title); ?></a>
<?php if ( $this->params->get('show_cat_num_articles', 1)) : ?>
<span class="badge badge-info tip hasTooltip" title="<?php echo JHtml::_('tooltipText', 'COM_CONTENT_NUM_ITEMS_TIP'); ?>">
<?php echo JText::_('COM_CONTENT_NUM_ITEMS'); ?>&nbsp;
<?php echo $child->getNumItems(true); ?>
</span>
<?php endif; ?>

<?php if ($this->maxLevel > 1 && count($child->getChildren()) > 0) : ?>
<a href="#category-<?php echo $child->id; ?>" data-toggle="collapse" data-toggle="button" class="btn btn-mini pull-right"><span class="icon-plus"></span></a>
<?php endif; ?>
</h3>
<?php endif; ?>
</h3>
<?php else : ?>
<h3 class="page-header item-title"><a href="<?php echo JRoute::_(ContentHelperRoute::getCategoryRoute($child->id)); ?>">
<?php echo $this->escape($child->title); ?></a>
<?php if ( $this->params->get('show_cat_num_articles', 1)) : ?>
<span class="badge badge-info tip hasTooltip" title="<?php echo JHtml::_('tooltipText', 'COM_CONTENT_NUM_ITEMS_TIP'); ?>">
<?php echo JText::_('COM_CONTENT_NUM_ITEMS'); ?>&nbsp;
<?php echo $child->getNumItems(true); ?>
</span>

<?php if ($this->params->get('show_subcat_desc') == 1) : ?>
<?php if ($child->description) : ?>
<div class="category-desc">
<?php echo JHtml::_('content.prepare', $child->description, '', 'com_content.category'); ?>
</div>
<?php endif; ?>
<?php endif; ?>

<?php if ($this->maxLevel > 1 && count($child->getChildren()) > 0) : ?>
<a href="#category-<?php echo $child->id; ?>" data-toggle="collapse" data-toggle="button" class="btn btn-mini pull-right"><span class="icon-plus"></span></a>
<div class="collapse fade" id="category-<?php echo $child->id; ?>">
<?php
$this->children[$child->id] = $child->getChildren();
$this->category = $child;
$this->maxLevel--;
echo $this->loadTemplate('children');
$this->category = $child->getParent();
$this->maxLevel++;
?>
</div>
<?php endif; ?>
</h3>
<?php endif; ?>

<?php if ($this->params->get('show_subcat_desc') == 1) : ?>
<?php if ($child->description) : ?>
<div class="category-desc">
<?php echo JHtml::_('content.prepare', $child->description, '', 'com_content.category'); ?>
</div>
<?php endif; ?>
<?php endif; ?>

<?php if ($this->maxLevel > 1 && count($child->getChildren()) > 0) : ?>
<div class="collapse fade" id="category-<?php echo $child->id; ?>">
<?php
$this->children[$child->id] = $child->getChildren();
$this->category = $child;
$this->maxLevel--;
echo $this->loadTemplate('children');
$this->category = $child->getParent();
$this->maxLevel++;
?>
</div>
<?php endif; ?>
</div>
<?php endif; ?>
<?php endforeach; ?>

Expand Down