Skip to main content
code formatted according to coding standards
Source Link
AjitS
  • 10.9k
  • 7
  • 41
  • 73

Let you try with this code. Clear performance cacahecache.

function example_block_info() {
  $blocks['my-block-id'] = array(
    'info' => t('Block Name'),
  );
  return $blocks;
}
 
/**
 * Implementation of hook_block_view().
 */
function example_block_view($delta='') {
  $block = array();
  switch ($delta) {
    case 'my-block-id':
      $block['subject'] = t('Block Name');
      $block['content'] = example_contents();
      break;
  }
  return $block;
}
 
/**
 * custom html block
 * @return string
 */
function example_contents() {
  return '
    </p><div class="body">
      Hello World, this is a example custom Block
    </div><p>
  ';
}

$blocks['my-block-id'] = array( 'info' => t('Block Name'), ); return $blocks; }

/**

  • Implementation of hook_block_view(). */ function example_block_view($delta='') { $block = array(); switch ($delta) { case 'my-block-id': $block['subject'] = t('Block Name'); $block['content'] = example_contents(); break; } return $block; }

/**

  • custom html block
  • @return string */ function example_contents() { return '

    Hello World, this is a example custom Block

'; }

For more info see this http://www.summasolutions.net/blogposts/how-create-basic-block-code-new-drupal-7

Let you try with this code. Clear performance cacahe.

function example_block_info() {

$blocks['my-block-id'] = array( 'info' => t('Block Name'), ); return $blocks; }

/**

  • Implementation of hook_block_view(). */ function example_block_view($delta='') { $block = array(); switch ($delta) { case 'my-block-id': $block['subject'] = t('Block Name'); $block['content'] = example_contents(); break; } return $block; }

/**

  • custom html block
  • @return string */ function example_contents() { return '

    Hello World, this is a example custom Block

'; }

For more info see this http://www.summasolutions.net/blogposts/how-create-basic-block-code-new-drupal-7

Let you try with this code. Clear performance cache.

function example_block_info() {
  $blocks['my-block-id'] = array(
    'info' => t('Block Name'),
  );
  return $blocks;
}
 
/**
 * Implementation of hook_block_view().
 */
function example_block_view($delta='') {
  $block = array();
  switch ($delta) {
    case 'my-block-id':
      $block['subject'] = t('Block Name');
      $block['content'] = example_contents();
      break;
  }
  return $block;
}
 
/**
 * custom html block
 * @return string
 */
function example_contents() {
  return '
    </p><div class="body">
      Hello World, this is a example custom Block
    </div><p>
  ';
}

For more info see this http://www.summasolutions.net/blogposts/how-create-basic-block-code-new-drupal-7

Source Link
Sathiya
  • 512
  • 3
  • 8

Let you try with this code. Clear performance cacahe.

function example_block_info() {

$blocks['my-block-id'] = array( 'info' => t('Block Name'), ); return $blocks; }

/**

  • Implementation of hook_block_view(). */ function example_block_view($delta='') { $block = array(); switch ($delta) { case 'my-block-id': $block['subject'] = t('Block Name'); $block['content'] = example_contents(); break; } return $block; }

/**

  • custom html block
  • @return string */ function example_contents() { return '

    Hello World, this is a example custom Block

'; }

For more info see this http://www.summasolutions.net/blogposts/how-create-basic-block-code-new-drupal-7