Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I'm trying to add custom search parameters after the start date and end date such as city (attached image) but it seems that the feature in the code base hasn't been built to allow this yet. When I look at line 1823 in file rooms_booking_manager.module
function rooms_booking_manager_get_plugin_parameters($form_state) {
$plugins_values = array();
$query = array();
ctools_include('plugins');
$filters = ctools_get_plugins('rooms_booking', 'availabilityagent_filter');
foreach ($filters as $filter) {
$class = ctools_plugin_get_class($filter, 'handler');
$plugins_values += $class::availabilitySearchParameters();
}
dpm($plugins_values);
// Collect the values for booking parameters.
foreach ($plugins_values as $value) {
if (isset($form_state['values'][$value])) {
$query[$value] = is_array($form_state['values'][$value]) ? implode(',', $form_state['values'][$value]) : $form_state['values'][$value];
}
}
return $query;
}
DPM always returns NULL. There doesn't seems to be a way (even though I extended AvailabilityAgentFilterBase) for me to specify custom parameters so I can later create a custom applyFilter() which would receive the city the customer selected.
Comment | File | Size | Author |
---|---|---|---|
#5 | ji_rooms.zip | 4.55 KB | JoshIdeas |
customsearch.png | 26.31 KB | JoshIdeas |
Comments
Comment #1
JoshIdeas CreditAttribution: JoshIdeas commentedI was able to get this to work by overriding this method. It was returning an empty array that's why there was never a value. Overriding this method with
works because inside of
you declare a new form field using the 'city' name as the parameter
such as
Comment #2
JoshIdeas CreditAttribution: JoshIdeas commentedComment #4
crustovich CreditAttribution: crustovich commentedI know this has been closed, but I am trying to implement this, and have got the drop down box to show on the Availability search, but don't know where/how to store the variables ie "beaver Creek" ect.
Any pointers please?
Thanks
Comment #5
JoshIdeas CreditAttribution: JoshIdeas commentedGood morning. I attached my module so you can dissect it.
In order to load 'Beaver Creek' or city field values you have to query the db, in this case I thought it simpler to use straight DB calls which were built into Drupal. See the snippet below:
(Located in ji_rooms_city_rooms_booking_availabilityagent_filter.inc line 50)
Notice the first line in the function
$cities = getCities();
which populates using this code
Of course all this is great but you can't forget to load the logic that allows rooms to check against the fields in the search. In other words, don't forget to populate logic in
public function applyFilter()
or else rooms won't 'filter' your newly created field