選択ボックスから値を保存するブロックを作成しようとしています。ただし、リロード後、variable_get は保存された値を返さないため、variable_set は機能しません。
ここで何が間違っていますか?(Drupal6)
function get_courses(){
global $user;
$my_items_sql = 'SELECT course_node.uid, ';
//get the course nid
$my_items_sql .='course_node.nid as course_nid, ';
//get the course title
$my_items_sql .='course_node.title as course_title ';
$my_items_sql .=' from node as course_node where course_node.type="course" and course_node.uid = "'.$user->uid.'"';
$my_items_sql .=' order by course_node.nid; ';
$my_items_data= db_query($my_items_sql);
$my_courses = array();
while ($row = db_fetch_array($my_items_data)) {
//$course_node = node_load($row["course_nid"]);
$my_courses[$row["course_nid"]]=$row["course_title"];
}
//$variables['courses']=$my_courses;
//drupal_add_js(array('courses'=>$my_courses), "setting");
return $my_courses;
}
function front_page_block($op='list',$delta = 0, $edit = array()) {
$course_options = array();
$courses = get_courses();
$tmp = $courses;
$first_course = $tmp;
reset($first_course );
$first_course_nid = key($first_course);
$first_course_nid = key($first_course);
switch($op){
case 'list':
$blocks[0]['info']= t('Course Data Loader');
$blocks[0]['cache']= BLOCK_NO_CACHE;
return $blocks;
case 'configure':
$form['course_to_display'] = array(
'#type' => 'select',
'#description' => t('Display flashcards from which deck on the front page?'),
'#options' => $courses,
'#default_value'=>variable_get('front_page_deck_to_load', $first_course_nid)
);
return $form;
case 'save':
variable_set('front_page_deck_to_load',
$edit['front_page_deck_to_load']);
break;
}