Skip to content

Commit

Permalink
fix parameter count in search and filter with tags are both 4
Browse files Browse the repository at this point in the history
  • Loading branch information
michb committed Jan 10, 2024
1 parent dc6675f commit 49c8500
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
10 changes: 8 additions & 2 deletions src/Resources/contao/classes/StoreLocator.php
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ public static function generateSearchValue( $arrData ): string {
$aData[1] = !empty($aData[1])?$aData[1]:'';
$aData[2] = $arrData['longitude'];
$aData[3] = $arrData['latitude'];
$aData[4] = '';
}
}

Expand Down Expand Up @@ -409,15 +410,20 @@ public static function createFilterWhereClause( string $searchValue, array $fiel
}

if( !empty($ret) ) {
$ret = '('.implode(" OR ",$ret).')';
$ret = '('.implode(" OR ", $ret).')';
} else {
$ret = '';
}

if( !empty($tagId) ) {

if( strlen($ret) ) {
$ret .= "AND ";
}

$ret .= "id IN ( SELECT s.id
FROM tl_storelocator_stores AS s
JOIN tl_tags_rel as r on (r.pid = s.id AND r.ptable = 'tl_storelocator_stores ' AND r.field = 'tags' AND r.tag_id=$tagId)
JOIN tl_tags_rel as r on (r.pid = s.id AND r.ptable = 'tl_storelocator_stores' AND r.field = 'tags' AND r.tag_id = $tagId)
)";
}

Expand Down
3 changes: 2 additions & 1 deletion src/Resources/contao/modules/ModuleStoreLocatorFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,14 @@ protected function compile(): void {
$widgetSubmit->label = $GLOBALS['TL_LANG']['tl_storelocator']['filter']['filter'];

$this->Template->labelReset = $GLOBALS['TL_LANG']['tl_storelocator']['filter']['filter_reset'];
$this->Template->hrefReset = $page->getFrontendUrl('/clear/filter');
$this->Template->hrefReset = Environment::get('request') . '/clear/filter';

if( Input::get('clear') == 'filter' ) {

$aSearchValues['filter'] = null;
$aSearchValues['order'] = null;
$aSearchValues['sort'] = null;
$aSearchValues['tags'] = null;

$strData = StoreLocator::generateSearchValue($aSearchValues);

Expand Down

0 comments on commit 49c8500

Please sign in to comment.