Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
Hi all, I just ran into this issue the other day. It seems that blocks that are not output on all pages do not trigger template_preprocess_block. This goes for any block (not just custom ones)
To duplicate the bug, simply add a block (eg. powered by Drupal) to the page via admin/build/blocks, configure the block to only show on one or more (but not all) pages, and you will find that template_preprocess_block is not called for the block.
You can determine that like so:
function ngTheme_preprocess_block(&$vars) {
dpm($vars);
}
If the block is set to output on all pages, then it is preprocessed.
Comments
Comment #1
mikemadison CreditAttribution: mikemadison at Pacific Northwest National Laboratory commentedI did a bit of initial testing on a clean Drupal 7.38 build. Nothing immediately jumps out at me in the changed files that would make this different in 7.37 vs. 7.38.
I used Bartik.
My code looked something like:
Note that Bartik fully spells out $variables, vs. $vars. Not sure if this matters in your theme.
When I change powered by Drupal to be "Only the listed pages" I used front as my parameter, and the dpm still fires on the homepage.
Any other hints on what I might be doing differently than you are would be appreciated so I can try and repro.
Comment #2
derekwebb1 CreditAttribution: derekwebb1 commentedHmmm... that is odd. I tried changing the theme to Bartik and adding the Powered by block to the front page only and I still do not see it going through the preprocess (while looking at front page - or any other page). Are you sure you set it to display only on the front? Thanks for looking at this as well!
Comment #3
derekwebb1 CreditAttribution: derekwebb1 commentedI have found that once in a blue moon, preprocess does seem to be firing for blocks that exist only on one or a few pages, however I am not able to discern why they work every now and then, but usually not. On an aside, using dpm to dump out the variables in template_preprocess_block in block module, tends to give me OOM errors (even though there are only three blocks on the page)
Comment #4
derekwebb1 CreditAttribution: derekwebb1 commentedI have tried this with Bartik and no custom module blocks on any page and the results are the same. Interestingly, blocks get the html_id and get rendered ok, even if they don't pass through block.module template_preprocess_block()... This is the strangest error I think I've ever seen with Drupal.
Comment #5
derekwebb1 CreditAttribution: derekwebb1 commentedJust found out that node preprocessing is not working on my site either... I am running very few modules, and the names are correct. I had been running panels and panelizer but I uninstalled them earlier.