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

  • Home
  • SEARCH
  • 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 7676807
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T17:16:56+00:00 2026-05-31T17:16:56+00:00

I have two block (like Block1 and Block2) and I have to display one

  • 0

I have two block (like Block1 and Block2) and I have to display one block among two. Condition is Block1 will be display into the whole site if Block2 is not present there. Block2 will be displayed into specific pages which is controlled dynamically, i.e. when user create content in future they can control the Block2 display. So I need to display Block1 where Block2 is not present.

I am using Durpal 7.

Note: I have tried with default block visibility but this is not worked for me either.

  • 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-31T17:16:57+00:00Added an answer on May 31, 2026 at 5:16 pm

    You can do that in many ways.

    Using template_preprocess_page() in your theme’s template.php file.
    You will need the 2 blocks printed on the page. Block1 and Block2.
    I’ll assume that Block1 resides in region_1 and block_2 resides in region_2 and your theme name is mytheme.

    inside your template_preprocess_page() function in theme’s template.php file:

    function mytheme_preprocess_page(&$variables)
    {
        if(isset($variables['page']['region_2']['block2']))
        {
            hide($variables['page']['region_1']['block1']);
        }
    }
    

    This way, Block1 will never be printed if Block2 is present.

    Hope it helps,

    Muhammad.

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

Sidebar

Related Questions

I have a list like this: <div> <ul> <li>one</li> <li>two</li> <li>three</li> <li>four</li> </ul> </div>
I have the following two code blocks. Code block 1 var checkboxes = $(div.c1
I have an abstract entity called Block which contains two attributes: column and order
I have the same block of code repeated with two different variables. This block
Have two actionsheet buttons and one modalviewcontroller on mainviewcontroller in application. Now for two
I have the following list structure: <ul> <li>One</li> <li>Two <ul> <li class=active>Two-1</li> <li>Two-2</li> </ul>
I have a two sprite images. One image contains the body of a rounded
I have the following html: <li> <span class=one>Stuff here</span> <span class=two>More stuff</span> </li> .one
I have two Drupal aggregator blocks on my page, one for a Twitter feed,
I have two divs, inline. One displays a measurement, the other displays a unit

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.