You are here

public function dsRegionToBlock::block_list in Display Suite 6.3

plugin block listing.

Make sure you create a unique name for your $block_key. You should return info & plugin so ds_block knows which block to load. You can add other info, which you'll receive back in block_list.

File

plugins/ds_extension/regiontoblock.inc, line 78

Class

dsRegionToBlock

Code

public function block_list($module, &$blocks, $data) {
  $api_info = ds_api_info($module);
  $types = $api_info['types']();
  if (!empty($types)) {
    foreach ($types as $type_key => $object) {
      $display_settings = array();
      $records = db_query("SELECT * FROM {ds_settings} WHERE module = '%s' AND type = '%s'", $module, $type_key);
      while ($row = db_fetch_object($records)) {
        $display_settings[$row->build_mode] = unserialize($row->settings);
      }
      foreach ($display_settings as $build_mode => $settings) {
        if (isset($settings['regiontoblock']['block'])) {
          foreach ($settings['regiontoblock']['block'] as $region => $value) {
            if ($value) {
              $block_key = 'ds_regiontoblock_' . $module . '_' . $object->type . '_' . $build_mode . '_' . $region;
              $block_info = $api_info['title'] . ': ' . $object->name . ', ' . $build_mode . ', ' . $region;
              $blocks[] = array(
                'info' => $block_info,
                'key' => $block_key,
                'data' => $data,
              );
            }
          }
        }
      }
    }
  }
}