code blog

Basic block module template

language: Drupal 6.x

Basic block module template

A simple template for an implementation of hook_block():

(sorry, no explanation, just a useful copy/paste starter for those who know how to use it)

function module_block($op = 'list', $delta = 0, $edit = array()){
	switch($op){
		case 'list':
			$blocks["delta"] = array(
				'info' => t('Admin title on list')
			);
			return $blocks;
		case 'view':
			if($delta=="delta"){
				$block['subject'] = t('Default title');
				$block['content'] = module_get_html_function();
			}
			return $block;
		case 'configure':
			//TODO: validation
			$form['setting'] = array(
			  '#type' => 'textfield', 
			  '#title' => t('Setting'), 
			  '#default_value' => variable_get('module_setting_'.$delta, '')
			);
			return $form;
		case 'save':
			//TODO: validation
			variable_set('module_'.$delta, $edit['setting']);
			break;			
	}
}

Comments

Coding Part

Hey buddy it is my final year of engineering and I am making project, so I was seeking for the same code, thanks you help me out.

box beaute

User login