Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8175751
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T22:53:13+00:00 2026-06-06T22:53:13+00:00

Is the hook_block has been changed? the following is drupal 6 example i have

  • 0

Is the hook_block has been changed? the following is drupal 6 example i have found on internet(http://eureka.ykyuen.info/2010/11/10/drupal-create-a-block/), there is no block shown in admin/structure/block,

     * Implementation of hook_block().

     */

    function custom_block($op = 'list', $delta = 0, $edit = array()) {

            switch ($op) {

                    //Define the block

                    case 'list':

                            $blocks[0]['info'] = t('Block Info');

                            $blocks[0]['cache'] = BLOCK_NO_CACHE;

                            return $blocks;



                    case 'configure':

                            //TODO: block configurable parameters

                            $form = array();

                            return $form;



                    case 'save':

                            //TODO: save new configuration

                            return;



                    //Display the block

                    case 'view':

                            $block['subject'] = t('Block Subject');

                            $block['content'] = 'Block Content';

                            return $block;

            }

    }

it seems that, hook_block in drupal 7 has been changed, how to rewrite about code? anyone can provide hints/direction to me? thank you very much.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T22:53:16+00:00Added an answer on June 6, 2026 at 10:53 pm

    In Drupal 7, your implementation of hook_block() would be changed to:

    /**
     * Implements hook_block_info().
     */
    function custom_block_info() {
      $blocks = array();
    
      $blocks['list'] = array(
        'info' => t('Block Info'),
        'cache' => DRUPAL_NO_CACHE,
      );
    
      return $blocks;
    }
    
    /**
     * Implements hook_block_view().
     */
    function custom_block_view($delta = '') {
      $block = array();
    
      switch ($delta) {
        case 'list':
          if (user_access('access content')) {
            $block['subject'] = t('Block Subject');
            $block['content'] = 'Block Content';
          }
          break;
      }
    
      return $block;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a custom module and am using hook_block to programmatically create some
I have the following code in my .emacs: (if (null window-system) (progn (require 'color-theme)
I know this has been asked countless times before, and they all seem to
I have emacs 23.3.1, running on windows. php-mode 1.5 from http://php-mode.sourceforge.net/ , Modified: 2008-11-04
I'm overriding hook_boot in my drupal 7.10 project, and trying to load a user
I have several dozen objects exposed through COM interfaces, each of which with many
I am initializing a number of items via hook_menu (Drupal 6) ... $items['webtv/block/%/playlist/edit/%'] =
This is a helper method I found in the ruby on rails application spree
some how i manage to have jquery transfer effect working with jquery dialog but
I'm running a pretty large drupal 7 website. I'd like to implement esi support

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.