Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Was pocking around in template.php and noticed there's no default case for $vars['build_mode'], so seemed like a good idea to add that in. Also, adding it as a class seems useful also.
Comment | File | Size | Author |
---|---|---|---|
#2 | build_mode_class-774838-2.patch | 1.23 KB | Anonymous (not verified) |
build_mode_class.patch | 603 bytes | hefox |
Comments
Comment #1
ceardach CreditAttribution: ceardach commentedYeah, I actually ended up adding my own build mode variable in my custom theme, too. +1 adding this to zen.
Comment #2
Anonymous (not verified) CreditAttribution: Anonymous commentedThis is a good idea, but doesn't fix a small bug.
The problem with the 'switch' statement is that it uses loose comparison. I'm not going to start defining arbitrary integers for my build modes, so I'm going to use strings.
When build mode is a string,
$node->build_mode == NODE_BUILD_NORMAL
. Constants are ideally compared with ===, but there's no way to get a switch statement to do this.This patch lets you keep the switch statement but it double checks that
$node->build_mode === NODE_BUILD_NORMAL
.Comment #3
Anonymous (not verified) CreditAttribution: Anonymous commentedThis patch fixes conflicts between Zen theme and potentially a handful of other modules that implement hook_content_build_modes that use strings as build mode identifiers.
See: http://drupalcontrib.org/api/search/6/_content_build_modes
Can we please please please commit this patch?
Comment #4
hefox CreditAttribution: hefox commentedIf NODE_BUILD_NORMAL is put right above default:, and break moved into the if statement {}, it can fallback to default cause if not NODE_BUILD_NORMAL, which I believe is desirable, right?
Comment #5
mlncn CreditAttribution: mlncn commentedTested, approved, and in use on production. Please commit!
Comment #6
JohnAlbinI just committed http://drupalcode.org/project/zen.git/commit/d90f68f
But, looking at this again, doesn't the current code's
if ($vars['node']->build_mode === NODE_BUILD_NORMAL)
mean that $vars['build_mode'] won't be set if the build mode loosely matches NODE_BUILD_NORMAL but doesn't exactly match NODE_BUILD_NORMAL?Don't we need this?
I committed the else clause as well. http://drupalcode.org/project/zen.git/commit/6a2a1ae
Please re-open if I'm off base.
Comment #7
hefox CreditAttribution: hefox commentedYep, the else statement was needed. Thanks :)
Comment #9
JohnAlbinWe need a corresponding view mode class in D7 as well. Just added it. :-)
http://drupalcode.org/project/zen.git/commit/bfea55e