function fieldblock_get_block_list in Field as Block 7
Helper function for fieldblock_block_info(). Builds a list of fields that have been made available as a block.
Return value
array An array with all fields that are made visible via the display fields UI, in the form of [fieldblock identifier] => [block description].
1 call to fieldblock_get_block_list()
- fieldblock_block_info in ./
fieldblock.module - Implements hook_block_info().
File
- ./
fieldblock.module, line 118 - Allow fields to be rendered in blocks.
Code
function fieldblock_get_block_list() {
$fieldblocks =& drupal_static(__FUNCTION__);
if (!isset($fieldblocks)) {
$fieldblocks = array();
$entities = entity_get_info();
// Loop over the entity types.
foreach ($entities as $entity_type => $entity_info) {
// Loop over each entity type's bundles.
foreach ($entity_info['bundles'] as $bundle => $bundle_info) {
$view_modes = field_view_mode_settings($entity_type, $bundle);
// Treat the default settings as a real view mode with custom settings.
$view_modes['default']['custom_settings'] = true;
// Loop over the bundle's view modes.
foreach ($view_modes as $view_mode => $view_mode_info) {
// Ignore this view mode if its custom settings are not enabled.
if (!$view_mode_info['custom_settings']) {
continue;
}
// Get the settings from the stored variable.
$variable_name = 'fieldblock-' . $entity_type . '-' . $bundle . '-' . $view_mode;
$fieldblock_settings = variable_get($variable_name, array());
// Loop over the fields defined in the variable.
foreach ($fieldblock_settings as $field_name => $field_label) {
// Build the fieldblock info.
$fieldblock_id = md5($variable_name . '-' . $field_name);
$fieldblocks[$fieldblock_id] = t('@field field (from @type: @bundle: @view_mode)', array(
'@field' => $field_label,
'@type' => $entity_type,
'@bundle' => $bundle_info['label'],
'@view_mode' => $view_mode,
));
}
}
}
}
}
return $fieldblocks;
}