function ddblock_content in Dynamic display block 6
Same name and namespace in other branches
- 7 ddblock.module \ddblock_content()
Get contents of dynamic display block block.
1 call to ddblock_content()
- ddblock_block in ./
ddblock.module - Implementation of hook_block().
File
- ./
ddblock.module, line 1511 - Enables your site to display dynamic content in a block.
Code
function ddblock_content($origin, $delta, $content = NULL, $teaser = NULL) {
// get settings.
$configuration_settings = ddblock_get_configuration_settings($origin, $delta);
// To Do
// Get settings per widget
$advanced = _ddblock_get_variable($configuration_settings, 'advanced', 0);
if ($advanced) {
$container = _ddblock_get_variable($configuration_settings, 'container', 'div.slide');
$pager_container = _ddblock_get_variable($configuration_settings, 'pager_container', 'custom-pager-item');
}
else {
$container = _ddblock_get_variable($configuration_settings, 'container', 'img');
$pager_container = _ddblock_get_variable($configuration_settings, 'pager_container', 'pager-item');
}
$content_type = _ddblock_get_variable($configuration_settings, 'content_type', 'none');
$custom_jquery = _ddblock_get_variable($configuration_settings, 'custom_jquery', '');
$fx = _ddblock_get_variable($configuration_settings, 'fx', "fade");
$height = _ddblock_get_variable($configuration_settings, 'height', 195);
$image_height = _ddblock_get_variable($configuration_settings, 'image_height', 183);
$image_width = _ddblock_get_variable($configuration_settings, 'image_width', 183);
$imgcache_toggle = _ddblock_get_variable($configuration_settings, 'imgcache_toggle', 0);
$imgcache_slide = _ddblock_get_variable($configuration_settings, 'imgcache_slide', '<none>');
$imgcache_pager_item = _ddblock_get_variable($configuration_settings, 'imgcache_pager_item', '<none>');
$image_container_height = $image_height + 12;
$image_container_width = $image_width + 12;
$input_type = _ddblock_get_variable($configuration_settings, 'input_type', 'images');
$next = _ddblock_get_variable($configuration_settings, 'next', 0);
$nodes = _ddblock_get_variable($configuration_settings, 'nodes', '');
$node_body_teaser = _ddblock_get_variable($configuration_settings, 'node_body_teaser', 'body');
$order = _ddblock_get_variable($configuration_settings, 'order', 'asc');
$output = _ddblock_get_variable($configuration_settings, 'output', 'view_content');
$overflow = _ddblock_get_variable($configuration_settings, 'overflow', 1);
if (!empty($overflow)) {
$overflow = 'hidden';
}
else {
$overflow = 'visible';
}
$pause = _ddblock_get_variable($configuration_settings, 'pause', 1);
$pager_toggle = _ddblock_get_variable($configuration_settings, 'pager_toggle', 0);
$pager = _ddblock_get_variable($configuration_settings, 'pager', 'none');
$pager_prev_next_loop = _ddblock_get_variable($configuration_settings, 'pager_prev_next_loop', 1);
$pager_scrollable_loop = _ddblock_get_variable($configuration_settings, 'pager_scrollable_loop', 1);
$nr_of_pager_items = _ddblock_get_variable($configuration_settings, 'nr_of_pager_items', 4);
$pager_event = _ddblock_get_variable($configuration_settings, 'pager_event', 'click');
$pager_fast = _ddblock_get_variable($configuration_settings, 'pager_fast', 1);
$pager_disable_click = _ddblock_get_variable($configuration_settings, 'pager_disable_click', 1);
$pager_pause = _ddblock_get_variable($configuration_settings, 'pager_pause', 1);
if ($pager == 'number-pager' || $pager == 'prev-next-pager') {
$pager_height = _ddblock_get_variable($configuration_settings, 'pager_height', 25);
$pager_width = _ddblock_get_variable($configuration_settings, 'pager_width', 195);
}
else {
$pager_height = _ddblock_get_variable($configuration_settings, 'pager_height', 63);
$pager_width = _ddblock_get_variable($configuration_settings, 'pager_width', 195);
}
$pager_position = _ddblock_get_variable($configuration_settings, 'pager_position', 'top');
$slide_text = _ddblock_get_variable($configuration_settings, 'slide_text', 1);
$slide_text_jquery = _ddblock_get_variable($configuration_settings, 'slide_text_jquery', 0);
$slide_text_after_effect = _ddblock_get_variable($configuration_settings, 'slide_text_after_effect', 'fadeIn');
$slide_text_after_speed = _ddblock_get_variable($configuration_settings, 'slide_text_after_speed', 1000);
$slide_text_before_effect = _ddblock_get_variable($configuration_settings, 'slide_text_before_effect', 'fadeOut');
$slide_text_before_speed = _ddblock_get_variable($configuration_settings, 'slide_text_before_speed', 250);
$slide_text_container = _ddblock_get_variable($configuration_settings, 'slide_text_container', 'div.slide-text');
$slide_text_position = _ddblock_get_variable($configuration_settings, 'slide_text_position', 'bottom');
$speed = _ddblock_get_variable($configuration_settings, 'speed', 500);
$template = _ddblock_get_variable($configuration_settings, 'template', 'none');
if ($template == 'custom') {
$custom_template = _ddblock_get_variable($configuration_settings, 'custom_template', '');
}
$timeout = _ddblock_get_variable($configuration_settings, 'timeout', 5000);
$widget = _ddblock_get_variable($configuration_settings, 'widget', 'cycle');
$width = _ddblock_get_variable($configuration_settings, 'width', 195);
// dsm($configuration_settings);
if ($template == 'none') {
// set imagecontainer height and width with jQuery
$settings['ddblockImageContainer'][$delta] = array(
'block' => $delta,
'contentContainer' => $container,
'imageContainerHeight' => $image_container_height,
'imageContainerWidth' => $image_container_width,
'setDimensions' => $template,
);
// set image heigth and width with jQuery
$settings['ddblockImages'][$delta] = array(
'block' => $delta,
'contentContainer' => $container,
'imageHeight' => $image_height,
'imageWidth' => $image_width,
'setDimensions' => $template,
);
}
// set jquery cycle settings
$settings['ddblockContent'][$delta] = array(
'block' => $delta,
'setDimensions' => $template,
'contentContainer' => $container,
'custom' => $custom_jquery,
'fx' => $fx,
'speed' => $speed,
'timeOut' => $timeout,
'pause' => $pause,
'next' => $next,
'overflow' => $overflow,
'pager' => $pager,
'pagerPrevNextLoop' => $pager_prev_next_loop,
'pagerScrollableLoop' => $pager_scrollable_loop,
'nrOfPagerItems' => $nr_of_pager_items,
'pagerContainer' => $pager_container,
'pagerEvent' => $pager_event,
'pagerDisableClick' => $pager_disable_click,
'pagerFast' => $pager_fast,
'pagerPause' => $pager_pause,
'slideText' => $slide_text,
'slideTextjQuery' => $slide_text_jquery,
'slideTextPosition' => $slide_text_position,
'slideTextContainer' => $slide_text_container,
'slideTextEffectBefore' => $slide_text_before_effect,
'slideTextEffectBeforeSpeed' => $slide_text_before_speed,
'slideTextEffectAfter' => $slide_text_after_effect,
'slideTextEffectAfterSpeed' => $slide_text_after_speed,
'height' => $height,
'width' => $width,
);
ddblock_init_js_css();
drupal_add_js($settings, 'setting');
// get module path to dynamic display block module
$ddblock_path = drupal_get_path('module', 'ddblock');
// get original block settings.
$ddblock = ddblock_get_blocks($delta);
$delta_original = $ddblock->delta_original;
$module_original = $ddblock->module;
$ddblock_enabled = $ddblock->enabled;
if ($ddblock_enabled) {
// get content from other blocks.
$block = module_invoke($module_original, 'block', 'view', $delta_original);
if ($widget == 'default') {
return $block['content'];
}
else {
if ($module_original == 'views') {
if ($output == 'view_fields') {
$output_type = 'view_fields';
// block.module has a delta length limit of 32, but deltas in the views module can
// be longer because view names can be 32 and display IDs can also be 32.
// So for very long deltas, md5 hashes are used.
if (strlen($delta_original) == 32) {
$hashes = variable_get('views_block_hashes', array());
if (!empty($hashes[$delta_original])) {
$delta_original = $hashes[$delta_original];
}
}
list($name, $display_id) = explode('-', $delta_original);
// Load the view
if ($view = views_get_view($name)) {
if ($view
->access($display_id)) {
$view
->preview($display_id);
$content = $view->result;
if (!empty($content)) {
switch ($order) {
case 'random':
shuffle($content);
break;
case 'asc':
asort($content);
break;
case 'desc':
rsort($content);
break;
case 'none':
break;
}
}
}
$view
->destroy();
}
}
else {
$output_type = 'view_content';
$content = $block['content'];
//return $block['content'];
}
}
else {
$output_type = 'view_content';
$content = $block['content'];
}
}
}
else {
if ($input_type != 'images') {
$output_type = 'content_array';
$content = _ddblock_get_content_array($content_type, $nodes, $node_body_teaser);
}
else {
// get content from image folderimages.
$output_type = 'images';
$imagepath = check_plain(_ddblock_get_variable(file_directory_path() . '/' . $configuration_settings, 'folder', file_directory_path()));
$max_image = _ddblock_get_variable($configuration_settings, 'max_image', 5);
$ignore_files = _ddblock_get_variable($configuration_settings, 'ignore_files', '');
$content = _ddblock_get_image_array($imagepath, $order, $max_image, $ignore_files);
}
}
if (!empty($content)) {
//use a settings array for template arguments which is more flexible
$settings = array(
'delta' => $delta,
'imgcache_pager_item' => $imgcache_pager_item,
'imgcache_toggle' => $imgcache_toggle,
'imgcache_slide' => $imgcache_slide,
'output_type' => $output_type,
'pager' => $pager,
'pager_position' => $pager_position,
'pager_height' => $pager_height,
'pager_width' => $pager_width,
'slide_text' => $slide_text,
'slide_text_position' => $slide_text_position,
'template' => $template,
'custom_template' => $custom_template,
'view_name' => $name,
'view_display_id' => $display_id,
'image_height' => $image_height,
'image_width' => $image_width,
);
$block_content = theme('ddblock_cycle_block_content', $settings, $content);
//dsm($block_content);
return $block_content;
}
else {
return false;
}
}