Skip to content

Commit

Permalink
# Fixed new 'categories' module to count items according to their
Browse files Browse the repository at this point in the history
multi-category assignments, fixed empty/unneeded div box appearing in
category view, when the new category layout selector is not used
  • Loading branch information
ggppdk committed May 8, 2015
1 parent 59051f7 commit 16179b0
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 7 deletions.
4 changes: 2 additions & 2 deletions modules/mod_flexicategories/tmpl/default_items.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
<h<?php echo $params->get('item_heading') + $levelup; ?>>
<a href="<?php echo $cat_link; ?>">
<?php echo $cat->title;?>
<?php if ($params->get('numitems')) : ?>
(<?php echo $cat->numitems; ?>)
<?php if ($params->get('numitems') && isset($globalcats[$cat->id])) : ?>
(<?php echo /*$cat->numitems*/ (int)(@$globalcats[$cat->id]->totalitems); ?>)
<?php endif; ?>
</a>
</h<?php echo $params->get('item_heading') + $levelup; ?>>
Expand Down
9 changes: 7 additions & 2 deletions plugins/system/flexisystem/flexisystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -425,14 +425,19 @@ static function getCategoriesTree()
global $globalcats;
$db = JFactory::getDBO();
$ROOT_CATEGORY_ID = FLEXI_J16GE ? 1 : 0;

$_nowDate = 'UTC_TIMESTAMP()';
$nullDate = $db->getNullDate();

// get the category tree and append the ancestors to each node
$query = 'SELECT c.id, c.parent_id, c.published, c.access, c.title, c.level, c.lft, c.rgt, c.language,'
. ' CASE WHEN CHAR_LENGTH(c.alias) THEN CONCAT_WS(\':\', c.id, c.alias) ELSE c.id END AS slug,'
. ' COUNT(rel.itemid) AS numitems'
. ' FROM #__categories as c'
. ' LEFT JOIN #__flexicontent_cats_item_relations AS rel ON c.id=rel.catid'
. ' LEFT JOIN #__content AS i ON rel.itemid=i.id AND i.state IN (1,-5)'
. ' LEFT JOIN #__content AS i ON rel.itemid=i.id '
. ' AND i.state IN (1,-5) '
. ' AND ( i.publish_up = '.$db->Quote($nullDate).' OR i.publish_up <= '.$_nowDate.' )'
. ' AND ( i.publish_down = '.$db->Quote($nullDate).' OR i.publish_down >= '.$_nowDate.' )'
. ' WHERE c.extension="'.FLEXI_CAT_EXTENSION.'" AND c.lft > ' . FLEXI_LFT_CATEGORY . ' AND c.rgt < ' . FLEXI_RGT_CATEGORY
. ' GROUP BY rel.catid'
. ' ORDER BY c.parent_id, c.lft'
Expand Down
5 changes: 2 additions & 3 deletions site/classes/flexicontent.helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -440,9 +440,8 @@ static function layout_selector(&$params, $formname='adminForm', $autosubmit=1,
else if ( ! is_array($allowed_tmpls) ) $allowed_tmpls = explode("|", $allowed_tmpls);

$_options = $type=='clayout' ? $displayed_tmpls : $allowed_tmpls;
if (!count($_options)) {
return '<input type="hidden" name="clayout" value="'.JRequest::getVar($type).'" />';
}
// Return if none allowed clayout(s) were configured
if (!count($_options)) return false;

$app = JFactory::getApplication();
$option = JRequest::getCmd('option');
Expand Down
4 changes: 4 additions & 0 deletions site/tmpl_common/listings_filter_form_body.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,11 @@

</div>
<!-- BOF items total-->

<?php endif; ?>

<?php if (!$clayout_selector) : ?>
<input type="hidden" name="clayout" value="<?php JRequest::getVar('clayout'); ?>" />
<?php endif; ?>

<?php if (JRequest::getCmd('print')) : ?>
Expand Down
4 changes: 4 additions & 0 deletions site/tmpl_common/listings_filter_form_body_html5.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,11 @@

</div>
<!-- BOF items total-->

<?php endif; ?>

<?php if (!$clayout_selector) : ?>
<input type="hidden" name="clayout" value="<?php JRequest::getVar('clayout'); ?>" />
<?php endif; ?>

<?php if (JRequest::getCmd('print')) : ?>
Expand Down

0 comments on commit 16179b0

Please sign in to comment.