Skip to content

Instantly share code, notes, and snippets.

@cafuego
Created July 9, 2012 06:22
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cafuego/3074521 to your computer and use it in GitHub Desktop.
Save cafuego/3074521 to your computer and use it in GitHub Desktop.
Drupal 7 Views Grid Preprocessor
<?php
/**
* Implements hook_preprocess_views_view_grid().
*
* Our own implementation removes the complete.css grid class names from
* the views grid and uses different ones instead.
*
* Specifically: col-N => view-col-N
*/
function phptemplate_preprocess_views_view_grid(&$vars) {
$replace = array();
for ($i = 1; $i <= ($vars['view']->style_options['columns']); $i++) {
$replace['col-'. $i .' '] = 'view-col-' . $i . ' ';
$replace['col-'. $i] = 'view-col-' . $i;
}
foreach ($vars['column_classes'] as &$row) {
foreach ($row as $column => &$classes) {
$classes = strtr($classes, $replace);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment