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 6669467
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:09:11+00:00 2026-05-26T03:09:11+00:00

Under Drupal 6 I have a custom block, which I have named and placed

  • 0

Under Drupal 6 I have a custom block, which I have named and placed into a custom, right-hand sidebar region. This block’s ID (which I have discovered from block.tpl.php, from the $block_id helper variable) is 7.

I am overriding the output of this block as it displays a View and I need to change the markup; I have a preprocess function in template.php called myTheme_preprocess_block() which searches for the block’s unique ID thus:

myTheme_preprocess_block(&$vars) {

    $this_block_id = $vars['id']; /* region-independent ID (for reliability) */
    $vars['template_files'] = array();

    switch ($this_block_id) {

        case 7:
            $vars['template_files'][] = 'block-my-override-template';
            break;
        default:
            /* take no action */
    }
}

Now, I’ve moved this block from the right-hand sidebar region (which is a custom region and not the default one which comes with Garland) to a footer region, which also has a custom name. And suddenly, my overriding template file, block-my-override-template.tpl.php, is no longer referenced.

I do a little digging and output the unique block ID from within block.tpl.php, and magically this block has changed its ID from 7 to 13! With a straight face, no less! Returning this block to the right-hand sidebar region also returns the block to ID 7 (and all my code starts working again).

My question is this: How can we uniquely identify a block if its “unique” ID changes when it moves from one region to another?

  • 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-05-26T03:09:12+00:00Added an answer on May 26, 2026 at 3:09 am

    If you are using a View, why don’t you instead override the block display of the View instead of mucking around with the actual block?

    You could alternatively simply declare your custom block in a module? That should make it easier for you to manage theming aspects of the block.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Scenario: I've defined a custom block in Drupal 6.20 under PHP 5.2.14. I've enabled
Under what circumstances would this or would this not be safe? I have a
I am using Drupal 7. I created a custom field for article nodes, which
I have created a menu in Drupal 7 and created links to pages under
Hi Suppose I have taxonomy test, and under this taxonomy, I have terms test2
I have a website which is up and running on drupal. Its product based
i have installed the fbconnect module under drupal 6. i have added <html xmlns:fb=http://www.facebook.com/2008/fbml
Under Windows XP WPF true 3D content (which is usually displayed using the Viewport3D
$viewName = 'my_view_name'; print views_embed_view($viewName); we have such a cool views_embed_view func. in Drupal
I have a new client that I am converting over to Drupal from Wordpress.

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.