$catSearchSelected = false;
$regionSearchSelected = false;
$mapItems = false;
+ $multiSelectCats = false;
// Paging Parameters
$paging = $this->config['settings']['list_pagination']; // Now this is in management
$nextStart = false;
$start = 1;
$limit = $this->config['settings']['list_pagination_count']; // Now this is in management
+
+ // Check if a multi-select for categories is being submitted. If so, assign that to the category selection
+ if (isset($_REQUEST['categorySearchMultiple']) && is_array($_REQUEST['categorySearchMultiple'])) {
+ $actionData['request']['category'] = implode(',', $_REQUEST['categorySearchMultiple']);
+ $multiSelectCats = true;
+ }
+
// Check for URL parameter override of shortcode parameters
if (isset($_REQUEST['categorySearch'])) {
$actionData['request']['category-search'] = $_REQUEST['categorySearch'];
}
- // If there's categories specified above ($cats array)
- if (count($cats) > 0) {
+ // If there's categories specified above ($cats array) - and we have category data
+ if (count($cats) > 0 && isset( $categoryData ) && is_array( $categoryData )) {
- /* * Restrict available categories for selection to those in shortcode or children
- * Note that the array is already ordered by parent then children then next parent
- * so $parentSelected
- */
- $parentSelected = false;
- if ( isset( $categoryData ) && is_array( $categoryData ) ) {
- reset($categoryData);
- while (list($k, $v) = each($categoryData)) {
+ // Check if this is a submitted multi-select for categories, set selected rather than remove other categories
+ if ($multiSelectCats) {
- // If this is a parent, then clear parent selected
- if ($v['parent_id'] != $parentSelected) {
- $parentSelected = false;
+ // Add ['default'] value to all categories
+ reset($categoryData);
+ while (list($k, $v) = each($categoryData)) {
+ $categoryData[$k]['default'] = false;
}
- // If category or parent is selected
- if ($parentSelected == false && !in_array($k, $cats)) {
+ // Now set that for the categories in $cats.
+ reset($cats);
+ foreach ($cats as $c) {
+ $categoryData[$c]['default'] = true;
+ }
- // Drop this category from the list
- unset($categoryData[$k]);
+ } else {
+
+ /* * Restrict available categories for selection to those in shortcode or children
+ * Note that the array is already ordered by parent then children then next parent
+ * so $parentSelected
+ */
+ $parentSelected = false;
+ reset($categoryData);
+ while (list($k, $v) = each($categoryData)) {
+
+ // If this is a parent, then clear parent selected
+ if ($v['parent_id'] != $parentSelected) {
+ $parentSelected = false;
+ }
+
+ // If category or parent is selected
+ if ($parentSelected == false && !in_array($k, $cats)) {
+
+ // Drop this category from the list
+ unset($categoryData[$k]);
+
+ // Otherwise, if this is a top-level category that's not dropped, save as currently selected parent
+ } elseif (!$v['parent_id']) {
+ $parentSelected = $k;
+ }
- // Otherwise, if this is a top-level category that's not dropped, save as currently selected parent
- } elseif (!$v['parent_id']) {
- $parentSelected = $k;
}
- }
- }
+ } // Not multiselect cats
}
$catSelectedForQuery = $catSelected;
// If we're doing category search selection Get category filter data
- if ($this->config['settings']['list_show_search_category']) {
+ if ($this->config['settings']['list_show_search_category'] && !$multiSelectCats) {
// Add default flag as false to all entries
if ( isset( $categoryData ) && is_array( $categoryData ) ) {