Yes, but only for the categories that have products with no attributes! It seems that the default function of the dynamic filter sidebox is to always show in categories with products regardless if they have attributes or not (shows empty sidebox with heading text).
I guess one would need to test if a given category has products with attributes and show the filter sidebox if true. Just don't know where or how to do this? Any suggestions? I'm sure others would like this feature as well!
Experience is what you get when you don’t get what you want…
Yes, I see what you mean, it would need a test to see if attributes are present. No doubt there's one hidden in the Zencart code somewhere. If you find it (or if you actually know the category that has no attributes) you can use this code to show/hide the sidebox for an 'if' statement
Replace the contents of includes/modules/sideboxes/YOUR_TEMPLATE/dynamic_filter.php with:
You can either change the [if ($cPath == '??')] value to your category or replace that code with the magical attribute test we've yet to find.PHP Code:<?php
/**
* dynamic_filter.php
*
*Zen Cart dynamic filter module
*Damian Taylor, March 2010
*
*/
if(FILTER_CATEGORY == 'Yes' && $current_page_base == 'index' && !$this_is_home_page && ($category_depth == 'products' || $category_depth == 'top') || FILTER_ALL == 'Yes' && $current_page_base == 'products_all' || FILTER_NEW == 'Yes' && $current_page_base == 'products_new' || FILTER_FEATURED == 'Yes' && $current_page_base == 'featured_products' || FILTER_SPECIALS == 'Yes' && $current_page_base == 'specials' || FILTER_SEARCH == 'Yes' && $current_page_base == 'advanced_search_result'){$show_dynamic_filter = true;
}
if ($cPath == '14'){
$show_dynamic_filter = false;}
if ($cPath == '6'){
$show_dynamic_filter = false;}
if ($show_dynamic_filter == true) {
require($template->get_template_dir('tpl_dynamic_filter.php',DIR_WS_TEMPLATE, $current_page_base,'sideboxes'). '/tpl_dynamic_filter.php');
$title = BOX_HEADING_FILTER;
$title_link = false;
require($template->get_template_dir($column_box_default, DIR_WS_TEMPLATE, $current_page_base,'common') . '/' . $column_box_default);
}
?>
OK, I see now. Most likely would want to test since I have several categories that currently don't have any attributes, but may in the future. Also, by testing, would make the dynamic filter more universal for others. May be add an admin switch to not show sidebox when products with no attributes in a category exist.
I'll work on this to see what I can come up with. Also, still interested in your responsive mods if you have them available!
Thanks,
kwright
Experience is what you get when you don’t get what you want…
Sounds good, adding an admin switch might be a bit beyond me though.
I'll put together a quick and dirty post on the responsive layout. I have found that there might still be a bit of work to finalise it - mainly that the filter collapses once an attribute is selected and it needs to be opened again to select another, you'll see what I mean though. I'll do it now and post shortly.
Responsive template mods - this should put an expandable 'filter button' at the top of the product listing page on displays less than 767px width.
---------------------------------------
in includes/templates/YOUR_TEMPLATE/sideboxes/tpl_dynamic_filter.php
replace:
with:PHP Code:// draw filter form
$content = '';
$content .= '<div id="' . str_replace('_', '-', $box_id . 'Content') . '" class="sideBoxContent">';
$content .= zen_draw_form('product_filter_form','', 'get');
----------------------------------------PHP Code:// draw filter form
$content = '';
$content .= '<div id="filterToggle"><a href="javascript:;" onclick="toggle_visibility(\'dynamicfilterContent\');">' . zen_image_button(BUTTON_IMAGE_TOGGLE_FILTER, BUTTON_TOGGLE_FILTER_ALT, 'class="listingBuyNowButton"') . '</a></div>';
$content .= '<div id="' . str_replace('_', '-', $box_id . 'Content') . '" class="sideBoxContent">';
$content .= zen_draw_form('product_filter_form','', 'get');
in your responsive.css or responsive_default.css file (depending on the template used) add under the @media (max-width:767px) section add:
in stylesheet.css add:Code:#dynamicfilter { display: block;visibility: visible;} #dynamicfilterContent{display:none;} #filterToggle {display: block;margin: 18px 0 0;} #dynamicfilterHeading {display: none;}
----------------------------------------Code:#filterToggle {display:none;}
in includes/languages/english/YOUR_TEMPLATE/button_names.php add:
BUTTON_TOGGLE_FILTER_ALT as well as being the image alt tag is also used for the css button text.PHP Code:define('BUTTON_IMAGE_TOGGLE_FILTER', 'buttonimage.gif');
define('BUTTON_TOGGLE_FILTER_ALT', 'Filter results');
BUTTON_IMAGE_TOGGLE_FILTER is an image file of the button if using images, if using css buttons this is not required but should be left blank like:
---------------------------------------Code:define('BUTTON_IMAGE_TOGGLE_FILTER', '');
in /includes/modules/pages/index add the attached jscript_toggle.js
jscript_toggle.zip
----------------------------------------
and that's it.
Now I come to think about it might be acceptable or even desirable for the filter box to collapse on page refresh especially on small screens. It would be good to know what others think.
Thanks simon1066 for your help and mods!![]()
Experience is what you get when you don’t get what you want…