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.
This doesn't work (at least in a subtheme):
$html5_respond_meta = theme_get_setting('zen_html5_respond_meta');
$variables['add_respond_js'] = in_array('respond', $html5_respond_meta);
$variables['add_html5_shim'] = in_array('html5', $html5_respond_meta);
$variables['default_mobile_metatags'] = in_array('meta', $html5_respond_meta);
.. because unchecking those values still leaves the item in the array albeit set to zero. This works, but looks ugly:
$variables['add_respond_js'] = in_array('respond', $html5_respond_meta) && $html5_respond_meta['respond'];
$variables['add_html5_shim'] = in_array('html5', $html5_respond_meta) && $html5_respond_meta['html5'];
$variables['default_mobile_metatags'] = in_array('meta', $html5_respond_meta) && $html5_respond_meta['meta'];
I leave it to your discretion to decide if you'd like it to be prettier :)
Comment | File | Size | Author |
---|---|---|---|
#5 | zen-1601000-5.patch | 897 bytes | star-szr |
#2 | zen-1601000-2.patch | 889 bytes | star-szr |
Comments
Comment #1
Aeternum CreditAttribution: Aeternum commentedSame issue here - quite a frustrating one to find
Comment #2
star-szrPrettier patch. Bumping to major, I don't think many themers will stop to figure out why this doesn't work, they will just move on.
Comment #3
Tor Arne Thune CreditAttribution: Tor Arne Thune commentedHit this one today. Not everyone wants to be responsive ;)
Comment #4
ruplWhatever solution is decided upon, the
$html5_respond_meta
var needs to end up cast as an array so we can avoid the PHP warnings I see on a fresh 7.x-5.1 install:The line numbers are 113, 114, 115 respectively with the patch from #2 applied.
Comment #5
star-szrHere's a patch that is NULL safe.
Comment #6
JohnAlbinWhoops!
Thanks for the patch! You're in the contributors list now. :-)
http://drupal.org/node/88566/committers
Comment #8
mavaddat CreditAttribution: mavaddat commentedThank you, Cottser! Your patch in #5 worked perfectly.
Comment #9
rooby CreditAttribution: rooby commentedJust for some extra info, to get it to work as it was with in_array() it should be:
Because you want a strict comparison.
Comment #9.0
rooby CreditAttribution: rooby commentedUpdated issue summary.