SPH, try this amendment to 'new files\includes\templates\YOUR_TEMPLATE\sideboxes\tpl_dynamic_filter.php' around line 250.
The lines you're adding are 'if ($attributes->RecordCount() > 0) {' and it's associated closing brace '}' near the end of the snippet.....
Code:
/********************************************start attribute link/check boxes***************************************************/
if(count($filteredProducts) > 0){
// Below line counts up all quantities of each item. e.g. if a glove is available in Small and Medium, quantity = 2.
//$attributes = $db->Execute("SELECT po.products_options_name, pov.products_options_values_name, count( p2as.quantity ) as quantity" .
$attributes = $db->Execute("SELECT count(DISTINCT p2a.products_id) as quantity, po.products_options_name, pov.products_options_values_name," .
" SUM(IF(p2a.products_id IN(" . implode(',', $filteredProducts) . "), 1, 0)) as flag" .
" FROM " . TABLE_PRODUCTS_ATTRIBUTES . " p2a ".
" JOIN " . TABLE_PRODUCTS_OPTIONS . " po ON p2a.options_id = po.products_options_id".
" JOIN " . TABLE_PRODUCTS_OPTIONS_VALUES ." pov ON p2a.options_values_id = pov.products_options_values_id".
(defined('TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK') ? " JOIN " . TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK . " p2as ON p2a.products_id = p2as.products_id AND p2as.stock_attributes LIKE CONCAT('%', p2a.products_attributes_id, '%')" : "") .
" WHERE p2a.products_id IN (" . implode(',', $unfilteredProducts) . ")" .
(FILTER_OPTIONS_INCLUDE != '' ? " AND p2a.options_id IN (" . FILTER_OPTIONS_INCLUDE . ")" : '') .
(FILTER_OPTIONS_EXCLUDE != '' ? " AND p2a.options_id NOT IN (" . FILTER_OPTIONS_EXCLUDE . ")" : '') .
(defined('TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK') ? " AND p2as.quantity > 0" : "") .
" GROUP BY po.products_options_name, pov.products_options_values_name" .
" ORDER BY po.products_options_name, pov.products_options_values_sort_order");
if ($attributes->RecordCount() > 0) {
$savName = '';
$savValue = '';
while (!$attributes->EOF) {
// output if option name changes!!!
if ($attributes->fields['products_options_name'] != $savName) {
$options_array = array();
if ($savName != "") {
$content .= '<hr width="90%" size="0" />';
$content .= '<div><div class="dFilter"><p class="dFilterHeading">' . DYNAMIC_FILTER_TEXT_PREFIX . htmlspecialchars(html_entity_decode($savName, ENT_QUOTES)) . DYNAMIC_FILTER_TEXT_SUFFIX . '</p>';
if (isset($_GET[$group]) && array_filter($_GET[$group])) $content .= '<div class="dFilterClear"><a href="' . zen_href_link($_GET['main_page'], zen_get_all_get_params(array($group)), 'NONSSL') . '">' . zen_image(DIR_WS_TEMPLATE_IMAGES . 'clear_filter.png', DYNAMIC_FILTER_BUTTON_CLEAR_FILTER_ALT) . '</a></div>';
if (strtok(FILTER_STYLE, " ") == 'Dropdown') $content .= '<select name="' . $group . '[]" class="dFilterDrop"' . (FILTER_STYLE == 'Dropdown - Single' ? ' onchange="this.form.submit();"' : '') . '>' . '<option value=""' . (!isset($_GET[$group]) || !array_filter($_GET[$group]) ? ' selected="selected"' : '') . '>' . $dropdownDefault . '</option>';
else $content .= '<ul' . ($attrCount > FILTER_MAX_OPTIONS ? (FILTER_OPTIONS_STYLE == 'Scroll' ? ' class="dFilterScroll">' : ' class="dFilterExpand">') : '>');
$content .= $filters;
if (strtok(FILTER_STYLE, " ") == 'Dropdown') $content .= '</select>';
else $content .= '</ul>';
if (FILTER_OPTIONS_STYLE == 'Expand' && $attrCount > FILTER_MAX_OPTIONS) $content .= '<a class="dFilterToggle" href="#">More' . zen_image(DIR_WS_TEMPLATE_IMAGES . 'arrow_more.gif', 'More', '', '', 'class="dFilterToggleImg"') . '</a>';
$content .= '</div></div>';
}
$group = DYNAMIC_FILTER_PREFIX . str_replace(' ', '', $attributes->fields['products_options_name']);
$resetParms[] = $group;
$parameters = zen_get_all_get_params();
$dropdownDefault = str_replace('%n', $attributes->fields['products_options_name'], DYNAMIC_FILTER_DROPDOWN_DEFAULT);
$filters = '';
$attrCount = 0;
}
if ($attributes->fields['products_options_values_name'] != $savValue) {
if (isset($_GET[$group]) && in_array($attributes->fields['products_options_values_name'],$_GET[$group])) $linkClass = 'selected';
else if (isset($_GET[$group]) && array_filter($_GET[$group]) && !in_array($attributes->fields['products_options_values_name'],$_GET[$group]) || $attributes->fields['flag'] == 0) $linkClass = 'disabled';
//else if ($attributes->fields['flag'] == 0) $linkClass = 'disabled';
else $linkClass = 'enabled';
$onClick = '';
if (FILTER_GOOGLE_TRACKING != 'No') $onClick .= $trackingStart . '\'filterAction\', \'' . ($linkClass != 'selected' ? 'addFilter' : 'removeFilter') . '\', \'' . $pageName . ';' . $attributes->fields['products_options_name'] . '=' . htmlspecialchars(html_entity_decode($attributes->fields['products_options_values_name'], ENT_QUOTES)) . '\'' . $trackingEnd;
if (FILTER_STYLE == 'Checkbox - Single') $onClick .= ' this.form.submit();';
if (FILTER_METHOD != 'Hidden' || $linkClass != 'disabled') {
$hrefLink = $group . '[]=' . rawurlencode($attributes->fields['products_options_values_name']);
switch(strtok(FILTER_STYLE, " ")) {
case 'Checkbox':
$filters .= '<li class="dFilterLink">' . zen_draw_checkbox_field($group . '[]', $attributes->fields['products_options_values_name'], (isset($_GET[$group]) && in_array($attributes->fields['products_options_values_name'],$_GET[$group]) ? true : false), ($linkClass == 'disabled' ? 'disabled="disabled"' : '') . ($onClick != '' && FILTER_STYLE == 'Checkbox - Single' ? ' onclick="' . $onClick . '"' : '')) . htmlspecialchars(html_entity_decode($attributes->fields['products_options_values_name'], ENT_QUOTES)) . '</li>';
break;
case 'Link':
$filters .= '<li class="dFilterLink"><a class="' . $linkClass . '"' . ($linkClass != 'disabled' ? ' rel="nofollow" href="' . zen_href_link($_GET['main_page'], ($linkClass != 'selected' ? $parameters . $hrefLink : str_replace(array($hrefLink,'&'.$hrefLink), array("",""), $parameters)), 'NONSSL') . '"' . ($onClick != '' ? ' onclick="' . $onClick . '"' : '') : '') . ' >' . htmlspecialchars(html_entity_decode($attributes->fields['products_options_values_name'], ENT_QUOTES)) . '</a></li>';
break;
case 'Dropdown':
$filters .= '<option value="' . htmlspecialchars(html_entity_decode($attributes->fields['products_options_values_name'], ENT_QUOTES)) . '"' . ($linkClass == 'selected' ? ' selected="selected"' : '') . ($linkClass == 'disabled' ? ' disabled="disabled"' : '') . ($onClick != '' && FILTER_STYLE == 'Dropdown - Single' ? ' onclick="' . $onClick . '"' : '') . ' >' . $attributes->fields['products_options_values_name'] . '</option>';
break;
}
++$attrCount;
}
}
$savValue = $attributes->fields['products_options_values_name'];
$savName = $attributes->fields['products_options_name'];
$attributes->MoveNext();
}
if ($savName != "") {
$content .= '<hr width="90%" size="0" />';
$content .= '<div><div class="dFilter"><p class="dFilterHeading">' . DYNAMIC_FILTER_TEXT_PREFIX . htmlspecialchars(html_entity_decode($savName, ENT_QUOTES)) . DYNAMIC_FILTER_TEXT_SUFFIX . '</p>';
if (isset($_GET[$group]) && array_filter($_GET[$group])) $content .= '<div class="dFilterClear"><a href="' . zen_href_link($_GET['main_page'], zen_get_all_get_params(array($group)), 'NONSSL') . '">' . zen_image(DIR_WS_TEMPLATE_IMAGES . 'clear_filter.png', DYNAMIC_FILTER_BUTTON_CLEAR_FILTER_ALT) . '</a></div>';
if (strtok(FILTER_STYLE, " ") == 'Dropdown') $content .= '<select name="' . $group . '[]" class="dFilterDrop"' . (FILTER_STYLE == 'Dropdown - Single' ? ' onchange="this.form.submit();"' : '') . '>' . '<option value=""' . (!isset($_GET[$group]) || !array_filter($_GET[$group]) ? ' selected="selected"' : '') . '>' . $dropdownDefault . '</option>';
else $content .= '<ul' . ($attrCount > FILTER_MAX_OPTIONS ? (FILTER_OPTIONS_STYLE == 'Scroll' ? ' class="dFilterScroll">' : ' class="dFilterExpand">') : '>');
$content .= $filters;
}
if (strtok(FILTER_STYLE, " ") == 'Dropdown') $content .= '</select>';
else $content .= '</ul>';
if (FILTER_OPTIONS_STYLE == 'Expand' && $attrCount > FILTER_MAX_OPTIONS) $content .= '<a class="dFilterToggle" href="#">More' . zen_image(DIR_WS_TEMPLATE_IMAGES . 'arrow_more.gif', 'More', '', '', 'class="dFilterToggleImg"') . '</a>';
$content .= '</div></div>';
}
}
/********************************************end attribute link/check boxes***************************************************/
Bookmarks