logo

额外区块类型 (EBT) - 全新的布局构建器体验❗

额外区块类型 (EBT) - 样式化、可定制的区块类型:幻灯片、标签页、卡片、手风琴等更多类型。内置背景、DOM Box、JavaScript 插件的设置。立即体验布局构建的未来。

演示 EBT 模块 下载 EBT 模块

❗额外段落类型 (EPT) - 全新的 Paragraphs 体验

额外段落类型 (EPT) - 类似的基于 Paragraph 的模块集合。

演示 EPT 模块 滚动

滚动

hook_block_info 的问题

22/02/2025, by 匿名 (未验证)
论坛

 

 您好!

我正在尝试通过编程创建区块。

在我的模块中这样做

function about_block_info(){
	$blocks['about_company'] = array(
		'info' => '关于公司',
		'status' => TRUE,
		'region' => '',
		'weight' => 0,
		'visibility' => 1,
		'cache' => DRUPAL_NO_CACHE,
	);
	
	$blocks['first_red_text_item'] = array(
		'info' => '红色区块第一列的弹出文本(主页)',
		'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' => '主页区块标题',
			'#size' => 15,
			'#description' => '例如:“关于公司”',
			'#default_value' => variable_get('about_company_title','关于公司'),
		);
		$form['about_content_text'] = array(
			'#type' => 'textarea',
			'#title' => '主页简短文本',
			"#rows" => 5,
			"#cols" => 20,
			'#description' => '将作为主页的预览文本显示',
			'#default_value' => variable_get('about_company_text','这是我们国家第一个正式注册的独立教育机构,当时还被称为苏联。它的目的是培养高水平的专业翻译人员,因为当时苏联没有类似的教育机构。'),
		);
		$form['address'] = array(
			'#type' => 'textfield',
			'#title' => '公司信息页面地址',
			'#size' => 15,
			'#description' => '例如:about',
			'#default_value' => variable_get('about_company_address','about'),
		);
		break;
	
	case 'first_red_text_item':
		$form['first_red_text'] = array(
			'#type' => 'textarea',
			'#title' => '弹出区块的文本(第一列)',
			"#rows" => 5,
			"#cols" => 20,
			'#description' => '弹出文本',
			'#default_value' => variable_get('first_red_text1',''),
		);
		 $form['first_red_text_address'] = array(
			'#type' => 'textfield',
			'#title' => '弹出文本所指向的页面地址',
			'#size' => 15,
			'#description' => '例如: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;

}

:

 

所以在管理界面中,“关于公司”区块出现并且一切正常,而第二个区块却没有。错误在哪里?