Mercurial > hg > rr-repo
comparison sites/all/modules/flexslider/flexslider_views/flexslider_views.module @ 2:b74b41bb73f0
-- Google analytics module
author | danieleb <danielebarchiesi@me.com> |
---|---|
date | Thu, 22 Aug 2013 17:22:54 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
1:67ce89da90df | 2:b74b41bb73f0 |
---|---|
1 <?php | |
2 | |
3 /** | |
4 * @file | |
5 * Adds Views plugins for FlexSlider | |
6 * | |
7 * @author Mathew Winstone <mwinstone@coldfrontlabs.ca> | |
8 */ | |
9 | |
10 /** | |
11 * Implements hook_views_api(). | |
12 */ | |
13 function flexslider_views_views_api() { | |
14 return array( | |
15 'api' => 3, | |
16 ); | |
17 } | |
18 | |
19 /** | |
20 * Add a preprocessor for flexslider for dealing with FlexSlider views | |
21 */ | |
22 function flexslider_views_preprocess_flexslider(&$vars) { | |
23 // Only run the preprocessor if it is a view | |
24 if (!empty($vars['view'])) { | |
25 // Prepare all data to be passed to theme_flexslider(). | |
26 $items = array(); | |
27 $view = $vars['view']; | |
28 $settings = array(); | |
29 $settings['optionset'] = $vars['options']['optionset']; | |
30 | |
31 $row_plugin = $view->style_plugin->row_plugin; | |
32 | |
33 foreach ($vars['rows'] as $id => $row) { | |
34 // Render the row into a slide | |
35 $view->row_index = $id; | |
36 $item['slide'] = $row_plugin->render($row); | |
37 | |
38 $items[] = $item; | |
39 } | |
40 | |
41 // Add the slide items to the variables | |
42 $vars['items'] = $items; | |
43 | |
44 // Add the attributes | |
45 $settings['attributes']['id'] = $vars['options']['id']; | |
46 | |
47 // Reset the options to the processed values | |
48 $vars['settings'] = $settings; | |
49 } | |
50 } |