Skip to content

Instantly share code, notes, and snippets.

@tsavory
Created June 5, 2012 22:44
Show Gist options
  • Save tsavory/2878615 to your computer and use it in GitHub Desktop.
Save tsavory/2878615 to your computer and use it in GitHub Desktop.
overcome ie7+ie8 lack of media query to perform layout switch. litwol piggybacked ride on omega multi-layout support. but he couldn't use media queries. so the aim was to provide different means to trigger layout change without relying on media query.
function hook_css_alter(&$css) {
if ('[your theme name]' == $GLOBALS['theme'] && ($theme = alpha_get_theme()) && $theme->settings['responsive']) {
$request_session = request_session_get(); // This is my internal api. tells me parameters about current widget request. namely what size it wants to be in this request... narrow or wide.
$old_grid = $theme->grid;
$layouts = $theme->grids['[your custom layout name]'];
$size_selector = [some selector criteria/request];
switch ($size_selector) {
case '1':
$layouts['layouts']['narrow']['enabled'] = FALSE;
break;
case '2':
$layouts['layouts']['wide']['enabled'] = FALSE;
break;
}
$new_grid = alpha_grid_css($theme->theme, $layouts, $theme->settings['responsive']);
if (!empty($new_grid)) {
foreach ($new_grid as &$item) {
unset ($css[$item['item']]);
}
}
$fill_old = array_keys($old_grid);
$fill_new = array_keys($new_grid);
$wanted_css_files = array_diff($fill_old, $fill_new);
foreach ($wanted_css_files as $file) {
$css[$file]['browsers'] = array('IE' => TRUE, '!IE' => TRUE);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment