You are here

views_photo_grid.module in Views Photo Grid 7

Same filename and directory in other branches
  1. 8 views_photo_grid.module

Module file for the Views Photo Grid module.

File

views_photo_grid.module
View source
<?php

/**
 * @file
 * Module file for the Views Photo Grid module.
 */

/**
 * Implements hook_views_api().
 */
function views_photo_grid_views_api() {
  return array(
    'api' => 3,
    'path' => drupal_get_path('module', 'views_photo_grid') . '/views',
  );
}

/**
 * Preprocesses variables for the photo grid template.
 */
function template_preprocess_views_photo_grid_style(&$vars) {
  $view = $vars['view'];
  $handler = $view->style_plugin;
  $rendered_fields = $handler
    ->render_fields($view->result);
  $image_field = $handler
    ->get_image_field_name();
  $vars['items'] = array();
  foreach ($rendered_fields as $key => $row) {
    if (!empty($row[$image_field])) {
      $vars['items'][] = $row[$image_field];
    }
  }
  $module_dir = drupal_get_path('module', 'views_photo_grid');
  drupal_add_css($module_dir . '/css/views-photo-grid.css');
  drupal_add_js(array(
    'viewsPhotoGrid' => array(
      'gridPadding' => $handler->options['grid_padding'],
    ),
  ), 'setting');
  drupal_add_js($module_dir . '/js/views-photo-grid.js');
}

Functions

Namesort descending Description
template_preprocess_views_photo_grid_style Preprocesses variables for the photo grid template.
views_photo_grid_views_api Implements hook_views_api().