Scroll
Issue with hook_block_info
Forums
Good day!
I'm trying to programmatically create blocks.
Here's what I'm doing in my module:
function about_block_info(){
$blocks['about_company'] = array(
'info' => 'About the Company',
'status' => TRUE,
'region' => '',
'weight' => 0,
'visibility' => 1,
'cache' => DRUPAL_NO_CACHE,
);
$blocks['first_red_text_item'] = array(
'info' => 'Popup text for the first column of the red block (homepage)',
'status' => TRUE,
'region' => '',
'weight' => 0,
'visibility' => 1,
'cache' => DRUPAL_NO_CACHE,
);
return $blocks;
}
function about_block_configure($delta){
$form = array();
switch($delta){
case 'about_company':
$form['about_content_title'] = array(
'#type' => 'textfield',
'#title' => 'Block title on the homepage',
'#size' => 15,
'#description' => 'For example: "About the Company"',
'#default_value' => variable_get('about_company_title','About the Company'),
);
$form['about_content_text'] = array(
'#type' => 'textarea',
'#title' => 'Mini text on the homepage',
"#rows" => 5,
"#cols" => 20,
'#description' => 'Will be displayed as preview text on the homepage',
'#default_value' => variable_get('about_company_text','This was the first officially registered independent educational institution in our country, which at that time was still called the USSR. It was created with the aim of training high-class professional translators, as there were no analogs of such educational institutions in the USSR at that time.'),
);
$form['address'] = array(
'#type' => 'textfield',
'#title' => 'Page address with company information',
'#size' => 15,
'#description' => 'For example: about',
'#default_value' => variable_get('about_company_address','about'),
);
break;
case 'first_red_text_item':
$form['first_red_text'] = array(
'#type' => 'textarea',
'#title' => 'Text for the popup block (first column)',
"#rows" => 5,
"#cols" => 20,
'#description' => 'Popup text',
'#default_value' => variable_get('first_red_text1',''),
);
$form['first_red_text_address'] = array(
'#type' => 'textfield',
'#title' => 'Page address that the popup text refers to',
'#size' => 15,
'#description' => 'For example: about',
'#default_value' => variable_get('first_red_text_address1',''),
);
break;
}
return $form;
}
function about_block_save($delta = '', $edit = array()){
switch($delta){
case 'about_company':
variable_set('about_company_title',$edit['about_content_title']);
variable_set('about_company_text',$edit['about_content_text']);
variable_set('about_company_address',$edit['address']);
break;
case 'first_red_text_item':
variable_set('first_red_text1',$edit['first_red_text']);
variable_set('first_red_text_address1',$edit['first_red_text_address']);
break;
}
return;
}
:
So, in the admin panel, the block "About the Company" appears and works correctly, but the second block does not. Where is the error?
- Log in to post comments