Add social link to user profile on ambassador page

Display the twitter account of ambassadors on the ambassador page.
- groups_social_link formatter module for link_fields
- fontawesome iconset to support font icons (CDN version)
- update of user profiles's profile teaser display suite settings

Change-Id: Ieba3b5ff047792625fdb23fb7ab498ee355e9dfc
This commit is contained in:
Marton Kiss 2015-08-22 12:51:17 +02:00
parent b967d01702
commit 59baa41584
8 changed files with 128 additions and 6 deletions

View File

@ -336,6 +336,16 @@ function groups_update_7117() {
drupal_flush_all_caches();
}
/**
* Enable groups social link module.
*/
function groups_update_7118() {
if (!module_exists('groups_social_link')) {
module_enable(array('groups_social_link'));
}
drupal_flush_all_caches();
}
/**
* Set language negotiation to URL based.
*/

View File

@ -23,7 +23,7 @@ function groups_ambassador_ds_field_settings_info() {
'format' => 'default',
'formatter_settings' => array(
'link' => '1',
'wrapper' => 'h2',
'wrapper' => 'h3',
'class' => '',
),
),
@ -56,11 +56,13 @@ function groups_ambassador_ds_layout_settings_info() {
'ds_content' => array(
0 => 'ds_user_picture',
1 => 'name',
2 => 'field_twitter_url',
),
),
'fields' => array(
'ds_user_picture' => 'ds_content',
'name' => 'ds_content',
'field_twitter_url' => 'ds_content',
),
'classes' => array(),
'wrappers' => array(

View File

@ -41,8 +41,8 @@ function groups_ambassador_strongarm() {
'visible' => TRUE,
),
'profile_teaser' => array(
'weight' => '5',
'visible' => TRUE,
'weight' => '11',
'visible' => FALSE,
),
),
'summary' => array(
@ -51,8 +51,8 @@ function groups_ambassador_strongarm() {
'visible' => TRUE,
),
'profile_teaser' => array(
'weight' => '5',
'visible' => TRUE,
'weight' => '10',
'visible' => FALSE,
),
),
),

View File

@ -10,6 +10,7 @@ dependencies[] = groups_ambassador
dependencies[] = groups_homepage
dependencies[] = menu
dependencies[] = page_manager
dependencies[] = groups_social_link
features[ctools][] = page_manager:pages_default:1
features[features_api][] = api:2
features[menu_links][] = main-menu_ambassador-program:ambassador-program

View File

@ -0,0 +1,5 @@
name = Groups Social Link
description = "Add a formatter to url fields that allows Admins to determine how links will be displayed"
package = groups
core = 7.x
files[] = groups_social_link.module

View File

@ -0,0 +1,90 @@
<?php
// Guide:
// http://www.metaltoad.com/blog/drupal-7-tutorial-creating-custom-formatters
/**
* Implements hook_field_formatter_info().
*/
function groups_social_link_field_formatter_info() {
return array(
'groups_social_link_formatter' => array(
'label' => t('Social Link'),
'field types' => array('link_field'),
'settings' => array(
'provider' => 'twitter',
),
),
);
}
/**
* Implements hook_field_formatter_settings_form().
*/
function groups_social_link_field_formatter_settings_form($field, $instance,
$view_mode, $form, &$form_state) {
$element = array();
$element['provider'] = array(
'#type' => 'select',
'#title' => t('Provider'),
'#description' => t('Select social provider'),
'#default_value' => $settings['provider'],
'#options' => array(
'twitter' => 'Twitter',
'weibo' => 'Weibo',
'facebook' => 'Facebook',
),
);
return $element;
}
/**
* Implements hook_field_formatter_settings_summary().
*/
function groups_social_link_field_formatter_settings_summary($field, $instance,
$view_mode) {
$display = $instance['display'][$view_mode];
$settings = $display['settings'];
$summary = t('Use a @provider provider to display link.', array(
'@provider' => $settings['provider'],
));
return $summary;
}
/**
* Implements hook_field_formatter_view().
*/
function groups_social_link_field_formatter_view($entity_type, $entity, $field,
$instance, $langcode, $items, $display) {
$settings = $display['settings'];
$element = array();
foreach ($items as $delta => $item) {
// dpm($item, 'item');
$url = $item['url']; // Getting the actual value
}
if (!empty($url)) {
$display_value = '';
switch ($settings['provider']) {
case 'twitter':
$glyphicon = 'fa-twitter';
$display_value = '@'.basename($url);
break;
case 'weibo':
$glyphicon = 'fa-weibo';
$display_value = '@'.basename($url);
break;
}
$element[0]['#markup'] = format_string(
'<div class="social-link social-link-@provider">'.
'<i class="fa @glyphicon" aria-hidden="true"></i>'.
'<a href="@url">@display_value</a>'.
'</div>',
array(
'@glyphicon' => $glyphicon,
'@provider' => $settings['provider'],
'@url' => $url,
'@display_value' => $display_value,
));
}
return $element;
}

View File

@ -50,9 +50,12 @@
font-family: "Open Sans",Helvetica,Arial,sans-serif;
color: #445059;
}
.views-row {
margin-bottom: 2em;
}
h3 {
margin-top: 10px;
margin-bottom: 20px;
margin-bottom: 0px;
a {
color: #2A4E68;
font-family: "Open Sans",Helvetica,Arial,sans-serif;
@ -61,6 +64,16 @@
line-height: 20px;
}
}
.social-link {
font-size: 12px;
i {
color: #888;
padding-right: 0.2em;
}
a {
color: #888;
}
}
}
// override of page defaults

View File

@ -22,6 +22,7 @@ function openstack_bootstrap_preprocess_page(&$variables) {
unset($variables['navbar_classes_array'][$key]);
$variables['navbar_classes_array'][] = 'navbar-os';
}
drupal_add_css('//netdna.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.css', array('type' => 'external'));
}
/**