Dealer Locator (type field extended)
Permalink
We needed to extend the dealer locator package so that type (category in SAP) would allow for single 'dealers' to be in multiple type(s) (1 to many). The following is the solution we came up with. This is added to the controller in the block. Comma delimited, but I'm sure could be extended to preferred delimiter in the form set up. Hope this helps anyone who might need this feature.
EDIT: I should note that this will only display unique types in the drop down on the dealer locator block.
IN THE BLOCK TOOLS DIRECTORY LINE 7
Would have used find_in_set, but doesn't seem to be supported in the framework.
EDIT: I should note that this will only display unique types in the drop down on the dealer locator block.
public function getDistinctTypes($appendAny = false) { $db = Loader::db(); $types = array(); $typeUnique = array(); $col = $db->getCol("SELECT DISTINCT type FROM DealerLocatorLocations ORDER BY type ASC"); if(is_array($col) && count($col)) { foreach($col as $val) { $types[$val] = $val; } foreach($types as $val){ $typeUnique[] = explode(',', $val); } $types = $this->dealerLocatorFlatten($typeUnique); } if($appendAny) {
Viewing 15 lines of 35 lines. View entire code block.
IN THE BLOCK TOOLS DIRECTORY LINE 7
$distanceList->filter('type','%'.$_REQUEST['type'].'%','LIKE');
Would have used find_in_set, but doesn't seem to be supported in the framework.