My problem is that depending on a running mode my Drupal website might have either regular permalinks, or pretty, aliased ones. And "Page specific visibility settings" for blocks on specific pages (Show on only the listed pages) do not work across the modes.

It would be logical if let's say: node/23 syntax could work in any case, but it seems that it doesn't.

Do I have to change every setting for every block every time I switch permalink structure? Or there is more flexible solution to this?

  • Can you be more specific about what you mean by modes? What does that mean 'change permalink structure?" Are you using the Pathauto module?
    – Adam S
    Commented Jun 26, 2011 at 9:37
  • I mean that sometimes it's the usual: domain.com/?q=node/23 and sometimes it's domain.com/about-us. "Page specific visibility settings" seem to work only for whatever version I have defined in there: node/23 works only for domain.com/?q=node/23 and about-us only for - domain.com/about-us
    – jayarjo
    Commented Jun 26, 2011 at 9:44
  • 1
    Page visibility settings, just like everything else, should always work with the internal path and not the alias. Not sure what you are experiencing there...
    – Berdir
    Commented Jun 26, 2011 at 10:49
  • Weird... I'm just doing a redesign for a theme, written by someone else and there are aliases everywhere for blocks in "Page specific visibility settings" section.
    – jayarjo
    Commented Jun 26, 2011 at 11:06

2 Answers 2


If you need to control block visibility then the Context module is the way to it.

(edit) If you use the Context module you won't have to mess around with these types of things and more importantly neither does Drupal which in fact makes it faster. You can read more about Blocks, Context and Panels, another alternative to Blocks, here.


Below is a solution that should work for domain.com/?q=node/23 AND domain.com/about-us (as in one of the comments), by using the Rules module.

Part 1: Rules block visibility

Have a look at the Rules block visibility module. Here is a quote from its project page:

The Rules block visibility module allows Rules components to be used to control block visibility. This provides Drupal administrators and developers extreme flexibility in controlling when blocks should be displayed on their websites, in addition to the default visibility options provided by Drupal.

The general idea is that if you can do it with Rules, you can use it to control block visibility, so the possibilities are limitless:

  • Need to show a block only for users registered more than a month ago?

  • Perhaps you have a block that must be shown only between 8am-5pm on weekdays?

  • What about displaying or hiding a block based on current weather conditions?

All of this can be done by using Rules block visibility.

With that, and as per the "if you can do it with Rules, you can use it to control block visibility" above, you've reduced your question to making Rules intercept the actual URLs your using.

Part 2: Create an appropriate Rules Component

The Rules block visibility module doesn't have a lot of documentation, except in the README.txt that comes with this module. Here is what the crucial part of it is (to get the idea):

Configuration is done on a per-block basis. To control a block visibility using a rule component, go to the block settings page, scroll down to the "Rules" tab, and select the Rules component that you want to use.

Notice that to be able to be used by this module, a Rules component must be constructed in a very specific way. See the next section for more information.

This module comes with 2 sample Rules Components, that should help to understand the concept behind it.

By looking at these samples, I was able to create another Rules Component which looks like so:

{ "rules_block_visibility_hide_block_for_user_1" : {
    "LABEL" : "Hide block for user 1",
    "PLUGIN" : "rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
      "module" : { "label" : "Module", "type" : "text" },
      "delta" : { "label" : "Delta", "type" : "text" },
      "result" : { "label" : "Result", "type" : "boolean", "parameter" : false }
    "IF" : [
      { "NOT data_is" : { "data" : [ "site:current-user:uid" ], "value" : "1" } }
    "DO" : [ { "data_set" : { "data" : [ "result" ], "value" : "1" } } ],
    "PROVIDES VARIABLES" : [ "result" ]

What this Rules Component does is "only" return a boolean (1 or 0), based on the condition if the user's uid is YES or NO equal to 1.

You should be able to import this rule in your own environment. After you do, you should replace the Rules Condition. Which in the example here was about which user is using the site, i.e. if it is YES or NO (a boolean, right?) the user with uid = 1.

With that, we're coming close to an actual answer to your question.

Part 3: Set Block Visibility using the Rules Component

Head over to the "Block" settings for the block(s) you want to hide. At the bottom of its settings, within the typical "Visibility settings", there is now (after you enabled the Rules block visibility module as in Part 1) an extra tab labeled "Rules". Using that tab will allow you to select a "Rules Component" that will do what's documented below that selection list field, ie: "Show this block only if the selected rule returns a positive value. Important: to be listed here, a block visibility rule must have specific parameters and return values.".

So to complete the picture, you just select the Rules Component from Part 2 (which you should have tuned to fit your URL requirements).

Part 4: Further refinements

If you have a lot of such nodes, you may want to also add the Rules URL Argument module to the mix. Have a look at my answer to "How to use the Rules module to implement a custom redirect for an outdated URL?" to get an idea what you can do with that module.

Note: it doesn't matter what type of block it is (created by a view, or something else), it works in all cases.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.