Drupal 7制作可滚动的Banner

需要的模块:config_pages(用于配置Banner图片,需要一个多图字段), flexslider, linkimage

function mymodule_block_info() {
  // This example comes from node.module.
  $blocks['banner'] = array(
    'info' => t('Banner'),
    'cache' => DRUPAL_NO_CACHE
  );

  return $blocks;
}

function mymodule_block_view($delta = '') {
  if($delta == 'banner') {

    $config = config_pages_config('banner');
    if ($config) {
      // load flexslider.
      $optionset = flexslider_optionset_load('default');
      flexslider_add('block-invest-banner', $optionset);
    }

    // render item.
    $items = array();
    foreach($config->raw()->field_banner_slider['und'] as $image_item) {
      $items[] = theme('linkimage_formatter', array('item' => $image_item, 'image_style' => 'newbanner'));
    }
    $item_list = theme('item_list', array('items' => $items, 'attributes' => array('class' => array('slides'))));
    return array(
      'content' => '
' . $item_list . '
', ); } }