Skip to content

Instantly share code, notes, and snippets.

@lsolesen
Created June 9, 2015 07:54
Show Gist options
  • Save lsolesen/8e38ebbc7201d8f8378e to your computer and use it in GitHub Desktop.
Save lsolesen/8e38ebbc7201d8f8378e to your computer and use it in GitHub Desktop.
Returns render array to be printed out whereever
function mglaman_social_links() {
$social_links = array(
'twitter' => array(
'title' => t('Twitter'),
'href' => 'https://twitter.com/nmdmatt'
),
'linkedin' => array(
'title' => t('LinkedIn'),
'href' => 'http://www.linkedin.com/in/mattglaman',
),
'github' => array(
'title' => t('GitHub'),
'href' => 'https://github.com/mglaman',
),
'drupal' => array(
'title' => t('Drupal'),
'href' => 'http://drupal.org/u/mglaman',
),
);
$menu_output = array();
$menu_output['#sorted'] = TRUE;
$menu_output['#theme_wrappers'][] = 'menu_tree';
foreach ($social_links as $key => $item) {
// Create render array for the menu link.
$element = array();
$element['#theme'] = 'menu_link';
$element['#attributes']['class'] = array(
'social--links',
);
$element['#network'] = $key;
$element['#title'] = '<i class="fa fa-' . $key . '">&nbsp;</i><span class="helper-text">' .$item['title'] . '</span>';
$element['#href'] = $item['href'];
$element['#localized_options'] = array('html' => TRUE, 'external' => true, 'target' => '_blank', 'absolute' => true);
// Add the menu_link item into the render array for the menu_tree.
$menu_output[$key] = $element;
}
return $menu_output;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment