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 :)

CommentFileSizeAuthor
#5 zen-1601000-5.patch897 bytesstar-szr
#2 zen-1601000-2.patch889 bytesstar-szr
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Aeternum’s picture

Same issue here - quite a frustrating one to find

star-szr’s picture

Priority: Normal » Major
Status: Active » Needs review
FileSize
889 bytes

Prettier 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.

Tor Arne Thune’s picture

Status: Needs review » Reviewed & tested by the community

Hit this one today. Not everyone wants to be responsive ;)

rupl’s picture

Status: Reviewed & tested by the community » Needs work

Whatever 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:

Warning: in_array() expects parameter 2 to be array, null given in zen_preprocess_html() (line 111 of /.../sites/all/themes/zen/template.php).
Warning: in_array() expects parameter 2 to be array, null given in zen_preprocess_html() (line 112 of /.../sites/all/themes/zen/template.php).
Warning: in_array() expects parameter 2 to be array, null given in zen_preprocess_html() (line 113 of /.../sites/all/themes/zen/template.php).

The line numbers are 113, 114, 115 respectively with the patch from #2 applied.

star-szr’s picture

Status: Needs work » Needs review
FileSize
897 bytes

Here's a patch that is NULL safe.

JohnAlbin’s picture

Status: Needs review » Fixed

Whoops!

Thanks for the patch! You're in the contributors list now. :-)

http://drupal.org/node/88566/committers

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

mavaddat’s picture

Thank you, Cottser! Your patch in #5 worked perfectly.

rooby’s picture

Just for some extra info, to get it to work as it was with in_array() it should be:

in_array('respond', $html5_respond_meta, TRUE);

Because you want a strict comparison.

rooby’s picture

Issue summary: View changes

Updated issue summary.