i want to create a custom block for dropdown list which i can display in all pages.
/*
*implements hook_menu().
*/
function dropdown_page_menu(){
$items = array();
$items['page/layout/%'] = array(
'title' => 'Select Layout',
'page callback' => 'drupal_get_form',
'page arguments' => array('dropdown_page_select_form'),
'access arguments' => array('access content'),
);
return $items;
}
/**
* Implements hook_theme().
*/
function dropdown_page_theme(){
return array(
'dropdown_page_select_form' => array('render element' => 'form',),
);
}
function dropdown_page_page(){
$content[] = l(t('select layout'),'page/layout/%');
return $content;
}
function dropdown_page_select_form($form, &$form_state){
$options = array(
'select' => t('Select'),
'layout_1' => t('Layout 1'),
'layout_2' => t('Layout 2'),
'layout_3' => t('Layout 3'),
);
$form['choice'] = array(
'#type' => 'select',
'#options' => $options,
'#title' => t('Select your layout'),
);
dsm($options);
$form['submit'] = array(
'#type' => 'submit',
'#value'=> t('Go'),
);
return $form;
}
function dropdown_page_select_form_submit($form, &$form_state){
switch ($form_state['values']['choice']) {
case layout_1: {
//echo 'hi';die;
drupal_goto("layout_1".$options);
break;
}
case layout_2: {
//echo 'no';die;
drupal_goto("layout_2".$options);
break;
}
case layout_3: {
drupal_goto("layout_3".$options);
break;
}
default: {
print 'Select it!';
}
}
drupal_set_message(t('Your layout %input', array('%input' => $form_state['value']['choice'])));
}