2, ); } /** * Implement hook_field_formatter_info(). */ function og_views_field_formatter_info() { return array( 'og_views_default' => array( 'label' => t('Organic groups Views'), 'field types' => array('list_text'), ), ); } /** * Implement og_get_fields(). */ function og_views_og_get_fields() { return array( 'group' => array( 'og_views' => array( 'title' => t('Groups views'), 'callback' => 'og_views_create_fields_group', 'field' => 'og_views', ), ), ); } /** * Get all the Views. */ function og_views_field_allowed_values() { $return = array(); foreach (views_get_all_views() as $view_id => $view) { if (empty($view->disabled)) { $view_name = check_plain($view->name); foreach($view->display as $display) { $return[$view_id . ' ' .$display->id] = $view_name . ' (' . check_plain($display->display_title) .')'; } } } return $return; } /** * Implement og_get_fields(). */ function og_views_og_get_fields() { $items['og_views'] = array( 'type' => array('group'), 'description' => t('Add organic groups Views field to fieldable entities that are groups.'), 'field' => array( 'field_name' => 'og_views', 'type' => 'list_text', 'cardinality' => 1, 'settings' => array('allowed_values' => '', 'allowed_values_function' => 'og_views_field_allowed_values'), ), 'instance' => array( 'label' => t('Groups views'), 'widget_type' => 'options_select', 'display' => array( 'full' => array( 'label' => 'hidden', 'type' => 'og_views_default', ), 'teaser' => array( 'label' => 'above', 'type' => 'og_list_default', ), ), ), ); return $items; } /** * Organic group views field formatter. * * @return * A rendered Views. */ function theme_field_formatter_og_views_default($variables) { $element = $variables['element']; $output = ''; if (!empty($element['#item']['gid'])) { $view = explode(' ', $element['#item']['gid']); $output = views_embed_view($view[0], $view[1]); } return $output; }