function template_preprocess_views_simpleads in SimpleAds 7
Same name and namespace in other branches
- 7.2 includes/theme.inc \template_preprocess_views_simpleads()
Preprocess for SimpleAds Views template. views-simpleads.tpl.php
File
- includes/
simpleads.theme.inc, line 140 - SimpleAds Theme.
Code
function template_preprocess_views_simpleads(&$vars) {
$tid = 0;
$ads = array();
$ad_settings = array();
$block_settings = array();
$view = $vars['view'];
$rows = $vars['rows'];
$options = $vars['options'];
$default_limit = variable_get('simpleads_default_ads_limit', 10);
$limit = property_exists($view->query, 'limit') ? check_plain($view->query->limit) : $default_limit;
if (count($rows) > 0) {
foreach ($rows as $i => $data) {
if (isset($data->field_field_ad_category[0])) {
$tid = $data->field_field_ad_category[0]['raw']['tid'];
$node = $data->_field_data['nid']['entity'];
$ads[] = _simpleads_ads_data($node);
}
}
}
$prefix = 'views-' . $view->name . '-' . $tid . '-' . rand(1, 1000);
$ad_settings['ads_height'] = $options['ads_height'];
$ad_settings['ads_width'] = $options['ads_width'];
$block_settings['ads_rotation_type'] = $options['ads_rotation_type'];
$block_settings['ads_rotation_delay'] = $options['ads_rotation_delay'];
$block_settings['block_delta'] = $prefix;
$vars['tid'] = $tid;
$vars['prefix'] = $prefix;
$vars['ads_list'] = _simpleads_render_ajax_template($ads, $tid, $limit, $ad_settings, $block_settings);
}