Kryptronic Software Support Forum

You are viewing this forum as a guest. Login to an existing account, or create a new account, to reply to topics and to create new topics.

#1 12-21-2016 08:53:46

zanart
Member
From: bedford
Registered: 04-02-2008
Posts: 1706

Product Filter Multi Select

NIck
The product filter doesn't seem to allow multi selections from the same filter anymore.
You can only select one option from each filter.
What is the thinking behind this?


Rob

Offline

 

#2 12-22-2016 08:07:52

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19798
Website

Re: Product Filter Multi Select

Cleaner, easier to use, you get more desirable result sets.  Consider these filters show up on mobile devices now.  In V8 they were disabled in mobile mode.  Now they're visible as there is no such thing as mobile mode with the new responsive design.

You could modify the {private}/apps/ecom/ECOM/includes/prodfilter.php to use checkboxes instead of selects, if you wish.  The ECOM_Prod::prodfilter() function will process either single-entry (select field - stock) or array-based (checkboxes possibly) fields properly.  Using the same file from your V8 install will give you a pretty good look at what you'd need to do to convert to checkboxes, but consider the reasons for doing it the newer way.  The results truly do end up making way more sense, not to mention the display issues with how long some of those checkbox lists can get.


Nick Hendler

Offline

 

#3 12-22-2016 08:32:50

zanart
Member
From: bedford
Registered: 04-02-2008
Posts: 1706

Re: Product Filter Multi Select

ECOM_Prod::prodfilter() has changed to only accept a single entry.
I have changed the ECOM_Prod::prodfilter() to take an array, and I have changed to checkboxes.
The product filter now works as I would expect it to work.

I do accept your point about a cleaner display and responsive design, and may revert back if I have any issues.


Rob

Offline

 

#4 03-21-2017 10:32:32

MIngram
Member
Registered: 03-21-2017
Posts: 2

Re: Product Filter Multi Select

Prod filters are now more prominent on the prod page and clearly work well until it comes to clearing the filter.  It is a bit long winded to go back in a click on the filter box name - why not have a 'clear filter' button?

Offline

 

#5 03-22-2017 09:45:18

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19798
Website

Re: Product Filter Multi Select

I'll look into that. Good suggestion.


Nick Hendler

Offline

 

#6 03-22-2017 10:55:32

MIngram
Member
Registered: 03-21-2017
Posts: 2

Re: Product Filter Multi Select

OK please keep me posted on that as I would implement straight away

Offline

 

#7 05-18-2018 19:50:39

sppars
Member
Registered: 01-25-2006
Posts: 301

Re: Product Filter Multi Select

I was looking for a way to clear the filter as well and came up with the following solution.

In apps\ecom\ECOM\includes\prodfilter.php, find the following code

Code:

print '<div class="kfloatleftcn kfilter"><input type="submit" name="' . $formid . '--SUBMIT" id="' . $formid . '--SUBMIT" value="Filter" ';

if (!(empty($enableajax))) {print 'style="display: none;" ';}

print '/></div>' . $eol;

and add the following underneath

Code:

$js_reset = 'jQuery(\'#' . $formid . '\').find(\'option\').prop(\'selected\', false);'; // Remove selected.

print '<div class="kfloatleftcn kfilter"><input type="submit" name="' . $formid . '--RESET" id="' . $formid . '--RESET" onclick="' . $js_reset . '" value="Reset" /></div>';

This generates a reset button that upon clicking removes all selected values from the filter options.

Offline

 

#8 05-19-2018 00:37:21

zanart
Member
From: bedford
Registered: 04-02-2008
Posts: 1706

Re: Product Filter Multi Select

It may be a bit cleaner to use the following code

Code:

print '<button class="kfloatleftcn kfilter" id="resetfilter">Reset</button>';
$js_docready = 'jQuery(\'#resetfilter\').click(function(){ajaxExec({\'primary\': \'ContentWithTitle\', \'callback\': \'ajaxExecResult\',\'app\': \'ecom\',\'ns\': \'catshow\',\'prodfilterdo\': \'1\', \'ref\': \''.$ref.'\'});});';
$this->append_global_array('core.js_docready',$js_docready)

This will ajax refresh the main content div without any filters applied, and doesn't use any inline js.

However, my prodlist.php is heavily modified from the original version so not sure if I have other hacks in there to get this to work.


Rob

Offline

 

#9 05-19-2018 18:12:20

sppars
Member
Registered: 01-25-2006
Posts: 301

Re: Product Filter Multi Select

Thanks Zanart, I didn't know inline js is frowned upon. Learned something new and will have to go and make a few changes on my codes.

I wasn't able to get your code to work though. Although, I do believe you are missing a semicolon on the last line which I added, but no luck. Also, I think your code will only work on categories and not product search and if ajax is disabled, will it still work?

I did revise my code to eliminate the inline js and it looks to be faster now too.

Code:

$js_reset = 'jQuery(\'#' . $formid . '--RESET\').click(function(){';
$js_reset .= 'jQuery(\'#' . $formid . '\').find(\'option\').prop(\'selected\', false);'; // Remove selected.
$js_reset .= '});'; 
$this->append_global_array('core.js_docready',$js_reset);

print '<div class="kfloatleftcn kfilter"><input type="submit" name="' . $formid . '--RESET" id="' . $formid . '--RESET" value="Reset" /></div>';

Offline

 

#10 05-21-2018 09:32:16

zanart
Member
From: bedford
Registered: 04-02-2008
Posts: 1706

Re: Product Filter Multi Select

I think your code will do exactly the same as mine.

It is always best to tag any js to the js_docready variable, and it is very easy to use.

There is also $this->append_global_array('core.js_windowload',$js_windowload); which adds any code to the windowload.


Rob

Offline

 

Board footer