1

I have set up my site to allow users to set a different theme for each node, which works fine. Some of my themes make use of blocks, so I created a custom blocks module added them programatically, which works fine. The problem comes when I need to enable them. When a user creates a new node, all of the themes are available but none of the blocks are enabled. I have to go in and enable each block manually for each theme on each node. Is there any way to basically programatically say "when this theme is enabled, enable this block in this region" so I don't have to manually enable each block?

Please note that I am using Drupal 6 and upgrading is not gonna happen any time within the next couple of months.

1 Answer 1

2

There isn't a way to perform programatic actions during the enabling of a theme. You can, however, have your custom blocks module add an entry to the database for the placement of the block into a theme's region, before that theme is enabled.

To do that, you would implement a database insert query, perhaps in your module's install function, that creates an entry in the blocks table for the block(s) in certain regions in any theme. You can create these entries whether the theme(s) are enabled or not.

The result will be that the block appears to be enabled when the theme is installed.

Here is a d.o forum post on the subject, with some helpful examples

1
  • Thanks so much, I wasn't sure if there was a way to do it in Drupal. Custom code it is!
    – Kyle
    Commented Jan 13, 2012 at 13:50

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.