From 341121861fb36626a0fc6e6e9e1067cfef8b7acd Mon Sep 17 00:00:00 2001 From: torvista <4391026+torvista@users.noreply.github.com> Date: Sun, 4 Dec 2022 11:52:40 +0100 Subject: [PATCH 1/3] correct unclosed div --- 1_Installation_files/includes/modules/product_finder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1_Installation_files/includes/modules/product_finder.php b/1_Installation_files/includes/modules/product_finder.php index 8eb1503..f8d8ebb 100644 --- a/1_Installation_files/includes/modules/product_finder.php +++ b/1_Installation_files/includes/modules/product_finder.php @@ -85,7 +85,7 @@ echo zen_draw_hidden_field('pf_dd3_prev', $pf_dd3_selected); ?> -
From 5a868198e5a41ad29f88abfe66d96e6028a9e416 Mon Sep 17 00:00:00 2001 From: torvista <4391026+torvista@users.noreply.github.com> Date: Sun, 4 Dec 2022 21:45:08 +0100 Subject: [PATCH 2/3] strict comparison --- 1_Installation_files/includes/modules/product_finder.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/1_Installation_files/includes/modules/product_finder.php b/1_Installation_files/includes/modules/product_finder.php index f8d8ebb..e7cfe2f 100644 --- a/1_Installation_files/includes/modules/product_finder.php +++ b/1_Installation_files/includes/modules/product_finder.php @@ -77,7 +77,7 @@ $pf_dd2_array = pf_get_subcategories($pf_dd1_selected); //build the array for dropdown2 $pf_dd3_array = pf_get_subcategories($pf_dd2_selected); //build the array for dropdown3 -$cp = isset($cPath) && $cPath != '' ? 'cPath=' . $cPath : ''; //if on a category page, stay there until a complete new selection made (redirect). If on another page, stay there too! +$cp = isset($cPath) && $cPath !== '' ? 'cPath=' . $cPath : ''; //if on a category page, stay there until a complete new selection made (redirect). If on another page, stay there too! echo zen_draw_form('productFinderform', zen_href_link($_GET['main_page'], $cp), 'post', 'id="productFinderform"'); //this action is overridden when JS in use //pass current states so code can determine what has changed on each submit and act according, or not. echo zen_draw_hidden_field('pf_dd1_prev', $pf_dd1_selected); @@ -123,5 +123,5 @@ '; ?>
- + From 711ae36e95ce01b0754c6619d3809158f7cd7a7d Mon Sep 17 00:00:00 2001 From: torvista <4391026+torvista@users.noreply.github.com> Date: Mon, 5 Dec 2022 09:50:15 +0100 Subject: [PATCH 3/3] misc changes l --- .../includes/modules/product_finder.php | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/1_Installation_files/includes/modules/product_finder.php b/1_Installation_files/includes/modules/product_finder.php index e7cfe2f..57430ea 100644 --- a/1_Installation_files/includes/modules/product_finder.php +++ b/1_Installation_files/includes/modules/product_finder.php @@ -1,4 +1,6 @@ 0)) {//noscript, a complete NEW selection has been made, so go to that category +if ($js_disabled && empty($_GET['pf_ns']) && ($post_dd1 === $prev_dd1) && ($post_dd2 === $prev_dd2) && ($post_dd3 > 0)) {//noscript, a complete NEW selection has been made, so go to that category $cp = $pf_base_category . '_' . $post_dd1 . '_' . $post_dd2 . '_' . $post_dd3; //destination category - $link = zen_href_link(FILENAME_DEFAULT, - 'cPath=' . $cp . '&pf_dd1_prev=' . $post_dd1 . '&pf_dd2_prev=' . $post_dd2 . '&pf_dd3_prev=' . $post_dd3 . '&pf_ns=1'); // pf_dd1/2/3_prev: used to populate dropdowns with the selected category data - zen_redirect($link); -} elseif (($post_dd1 != $prev_dd1) && ($post_dd1 > 0) && ($post_dd3 == $prev_dd3)) {//noscript, only dd1 has changed: reload the existing page but reset dd2 and dd3 + $link = zen_href_link(FILENAME_DEFAULT, 'cPath=' . $cp . '&pf_dd1_prev=' . $post_dd1 . '&pf_dd2_prev=' . $post_dd2 . '&pf_dd3_prev=' . $post_dd3 . '&pf_ns=1'); + zen_redirect($link); //final parameter is the post value to know what was completely selected +} elseif (($post_dd1 !== $prev_dd1) && ($post_dd1 > 0) && ($post_dd3 === $prev_dd3)) {//noscript, only dd1 has changed: reload the existing page but reset dd2 and dd3 $post_dd2 = -1; $post_dd3 = -1; -} elseif (($post_dd2 != $prev_dd2) && ($post_dd2 > 0) && ($post_dd3 == $prev_dd3)) {//noscript, only dd2 has changed: reload the existing page but reset dd3 +} elseif (($post_dd2 !== $prev_dd2) && ($post_dd2 > 0) && ($post_dd3 === $prev_dd3)) {//noscript, only dd2 has changed: reload the existing page but reset dd3 $post_dd3 = -1; } - +$pid = false; //get current page location if in a category -if (isset($cPath) && $cPath != '') {//$cPath is only set on a category/product page +if (isset($cPath) && $cPath !== '') {//$cPath is only set on a category/product page $pf_cPaths = explode('_', $cPath); - if ($pf_cPaths[0] != $pf_base_category) { + if (!empty($_GET['products_id'])) { + $pid = (int)$_GET['products_id']; + } + if ((int)$pf_cPaths[0] !== $pf_base_category) { $pf_cPaths = ''; } } else { @@ -71,14 +75,13 @@ } else { $pf_dd3_selected = -1; } - //prepopulate dropdowns when arriving at a product/category page inside the Product Finder parent category $pf_dd1_array = pf_get_subcategories($pf_base_category); //build the array for dropdown1 $pf_dd2_array = pf_get_subcategories($pf_dd1_selected); //build the array for dropdown2 $pf_dd3_array = pf_get_subcategories($pf_dd2_selected); //build the array for dropdown3 $cp = isset($cPath) && $cPath !== '' ? 'cPath=' . $cPath : ''; //if on a category page, stay there until a complete new selection made (redirect). If on another page, stay there too! -echo zen_draw_form('productFinderform', zen_href_link($_GET['main_page'], $cp), 'post', 'id="productFinderform"'); //this action is overridden when JS in use +echo zen_draw_form('productFinderform', zen_href_link($_GET['main_page'], $cp . ($pid ? '&products_id=' . $pid : '')), 'post', 'id="productFinderform"'); //this action is overridden when JS in use //pass current states so code can determine what has changed on each submit and act according, or not. echo zen_draw_hidden_field('pf_dd1_prev', $pf_dd1_selected); echo zen_draw_hidden_field('pf_dd2_prev', $pf_dd2_selected);