Drupal Hotel Module - Default Adult Rooms for Search Widget



Rooms Search Block

Use case: show Widget search block with custom default nights and adults [today, we can only show that block with '1' default value]

a)
hotel_booking.module:234

Add form element for block configuration

$form['default_nights'] = Array(
'#type' => 'select',
'#title' => t('Default Nights'),
'#default_value' => variable_get('hotel_booking_block_default_nights', '2'),
'#options' => Array(1 => 1,2 => 2,3 => 3,4 => 4,5 => 5,6 => 6,7 => 7,8 => 8 ),
'#description' => t('Select defaut value for Nights.'),
);
$form['default_adults'] = Array(
'#type' => 'select',
'#title' => t('Default Adults'),
'#default_value' => variable_get('hotel_booking_block_default_adults', '2'),
'#options' => Array(1 => 1,2 => 2,3 => 3,4 => 4,5 => 5,6 => 6,7 => 7,8 => 8 ),
'#description' => t('Select defaut value for Adults.'),
);

This is how block setting lookks like [admin/build/block/configure/uc_hotel/0]
setting screenshot

b)
hotel_booking.module:273
Save submitted values for default adultns and defaults nights [case 'save':]

variable_set('hotel_booking_block_default_adults', $edit['default_adults']);
variable_set('hotel_booking_block_default_nights', $edit['default_nights']);

c)
hotel_booking.module:339
Apply selected default value for nights for Search Room widget

'#default_value' => variable_get('hotel_booking_block_default_nights', '2') ,

d)
hotel_booking.module:357
Apply selected default value for adults for Search Room widget

'#default_value' => variable_get('hotel_booking_block_default_adults', '2') ,

sponsored by http://noteurbane.com

AllegatoDimensione
search_hotel.png8.5 KB
search_hotel-block-setting400px.png67.96 KB
image/png icon

Comments

Invia nuovo commento

  • Linee e paragrafi vanno a capo automaticamente.
  • Web page addresses and e-mail addresses turn into links automatically.

Maggiori informazioni sulle opzioni di formattazione.

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
18 + 1 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.