function mediafront_views_pre_render in MediaFront 6.2
Same name and namespace in other branches
- 6 mediafront.module \mediafront_views_pre_render()
- 7.2 views/mediafront.views.inc \mediafront_views_pre_render()
- 7 mediafront.module \mediafront_views_pre_render()
Views pre-render
File
- ./
mediafront.module, line 595
Code
function mediafront_views_pre_render($view) {
// Check ot make sure this is the block playlist.
if (variable_get('mediafront_block_playlist', '') == $view->name) {
// Get the preset for this view.
$preset = variable_get('mediafront_block_preset', '');
// Initialize our javascript.
$js = 'jQuery.media = jQuery.media ? jQuery.media : {};';
$js .= 'jQuery.media.nodes = jQuery.media.nodes ? jQuery.media.nodes : [];';
// Iterate through our results, and add the node objects to the page.
foreach ($view->result as $result) {
$node = isset($result->_field_data) && isset($result->_field_data['nid']) && isset($result->_field_data['nid']['entity']) ? $result->_field_data['nid']['entity'] : node_load($result->nid);
$js .= 'jQuery.media.nodes.push(' . mediafront_json_encode(mediafront_invoke_node($node, NULL)) . ');';
}
// Get the class of the first field.
$class = 'views-field-' . views_css_safe(array_shift(array_keys($view->field)));
// The JS file.
$js .= 'jQuery.media.fieldClass = "' . $class . '";';
$js .= 'jQuery.media.playerId = "mediafront_' . $preset . '";';
// Add this javascript to the main page.
drupal_add_js($js, 'inline');
// Add the playlist javascript.
drupal_add_js(drupal_get_path('module', 'mediafront') . '/js/mediafront.js');
}
}