'yachts', 'perPage' => '20', 'where' => 'active ="1"' . ' AND hide ="0"', 'loadUploads' => true, 'allowSearch' => true, 'useSeoUrls' => true, 'orderBy' => $customOrderBy, )); if(!@$_REQUEST['destinations']){ $_REQUEST['destinations']=-1; } if(!@$_REQUEST['type']){ $_REQUEST['type']=-1; } list($destinationsRecords, $destinationsMetaData) = getRecords(array( 'tableName' => 'destinations', 'where' => "num=".intval(@$_REQUEST['destinations']), 'limit' => '1', 'allowSearch' => false, )); $destinationsRecord = @$destinationsRecords[0]; // get first record list($yacht_typeRecords, $yacht_typeMetaData) = getRecords(array( 'tableName' => 'yacht_type', 'where' => "url ='".mysql_escape(@$_REQUEST['type'])."'", 'limit' => '1', 'allowSearch' => false, )); $yacht_typeRecord = @$yacht_typeRecords[0]; // get first record list($settingsRecords, $settingsMetaData) = getRecords(array( 'tableName' => 'settings', 'limit' => '1', 'allowSearch' => false, )); $settingsRecord = @$settingsRecords[0]; // get first record $resultsText=""; if($destinationsRecord){ $resultsText.=$destinationsRecord['name']; if($yacht_typeRecord){ $resultsText.=" and ".$yacht_typeRecord['name_plural']; } } elseif($yacht_typeRecord){ $resultsText.=$yacht_typeRecord['name_plural']; } elseif(@$_REQUEST['yacht_name_query']){ $resultsText.=$_REQUEST['yacht_name_query']; } #### // this function will determine what the URL is for each of the sorting links on the page // first click will give the order ASC // second click will give the order DESC // $sortingField options: rate, length, guests // usage: getSortingURL("rate"); function getSortingURL($sortingField) { // sorting for "rate" if ($sortingField == "rate") { // first click -> set order to ASC if ( @$_REQUEST['sort'] == "rateASC" ) { return array('param' => "sort=rateDESC", 'class' => "active sortdesc"); } // second click -> set order to DESC if ( @$_REQUEST['sort'] == "rateDESC" ) { return array('param' => "sort=rateASC", 'class' => "active sortasc"); } if ( !@$_REQUEST['sort'] || @$_REQUEST['sort'] ) { return array('param' => "sort=rateASC", 'class' => ""); } } // sorting for "length" if ($sortingField == "length") { // first click -> set order to ASC if ( @$_REQUEST['sort'] == "lengthASC" ) { return array('param' => "sort=lengthDESC", 'class' => "active sortdesc"); } // second click -> set order to DESC if ( @$_REQUEST['sort'] == "lengthDESC" ) { return array('param' => "sort=lengthASC", 'class' => "active sortasc"); } if ( !@$_REQUEST['sort'] || @$_REQUEST['sort'] ) { return array('param' => "sort=lengthASC", 'class' => ""); } } // sorting for "guests" if ($sortingField == "guests") { // first click -> set order to ASC if ( @$_REQUEST['sort'] == "guestsASC" ) { return array('param' => "sort=guestsDESC", 'class' => "active sortdesc"); } // second click -> set order to DESC if ( @$_REQUEST['sort'] == "guestsDESC" ) { return array('param' => "sort=guestsASC", 'class' => "active sortasc"); } if ( !@$_REQUEST['sort'] || @$_REQUEST['sort'] ) { return array('param' => "sort=guestsASC", 'class' => ""); } } return "?"; } function getCustomOrderBy($sort) { if (!@$sort) { return ""; } switch ($sort) { case "rateASC": return "CAST(rate_high_season AS UNSIGNED) ASC"; break; case "rateDESC": return "CAST(rate_high_season AS UNSIGNED) DESC"; break; case "lengthASC": return "yacht_length ASC"; break; case "lengthDESC": return "yacht_length DESC"; break; case "guestsASC": return "guests_night ASC"; break; case "guestsDESC": return "guests_night DESC"; break; } return ""; } ?>