function theme_media_gallery_collection in Media Gallery 7.2
Same name and namespace in other branches
- 7 media_gallery.theme.inc \theme_media_gallery_collection()
Displays a collection of galleries as a grid of teasers.
File
- ./
media_gallery.theme.inc, line 11 - Media Gallery Theming
Code
function theme_media_gallery_collection($variables) {
$element = $variables['element'];
$collection = $element['#term'];
$columns = $collection->media_gallery_columns[LANGUAGE_NONE][0]['value'];
$grid = '<div class="media-gallery-collection mg-collection-' . $collection->vocabulary_machine_name . ' mg-col mg-col-' . $columns . '">';
foreach (element_children($element['nodes']) as $nid) {
// This invokes node.tpl.php, and where that calls render($content),
// theme_media_gallery_teaser() is called.
// Add the term to the node so that we can use it to configure the meta data
$element['nodes'][$nid]['#node']->term = $collection;
$teaser = drupal_render($element['nodes'][$nid]);
// @todo Implement real display needs.
$cell = $teaser;
$grid .= $cell;
}
$grid .= '</div>';
// Replace the 'nodes' element with the rendered grid while preserving its
// weight, so that other fields that are part of the collection term get
// rendered normally, and in the correct order.
$weight = isset($element['nodes']['#weight']) ? $element['nodes']['#weight'] : 0;
$element['nodes'] = array(
'#markup' => $grid,
'#weight' => $weight,
);
$output = drupal_render_children($element);
return $output;
}