Project:Janrain Engage (formerly RPX)
Version:7.x-2.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:active

Issue Summary

It would be great if we could use the Social Login icons as a Block and be able to put it anywhere we like.

I've made an attempt to expose the Social Login icons as a Block, but I did not succeed yet.
People that have code suggestions for that:
have a look at http://drupal.org/sandbox/s1l/1315560
you can easily add it to the function rpx_extras_socialloginicons_contents() and you're set.
(might save some time testing).
Once it's tested I suggest we commit it to the Janrain Engage module.

btw, using these as a block this is probably not the best solution for putting the icons on the registration page
#1207816: Include sign-in icons on the registration page
or for attaching it to the comments, but it would depend on your usecase I guess.

AttachmentSize
social-login-icons-block.jpg22.63 KB

Comments

#1

I want to second this, would really like this feature as well.

#2

Ad these lines to the end of rpx_widgets.module file.

It practically takes the code from _rpx_user_login_form_alter() and embed it into a block named "RPX Block Icons".

/**
* Implements hook_block_info().
*
* This hook declares what blocks are provided by the module.
*/
function rpx_widgets_block_info() {

  $blocks['rpx_block_icons'] = array(
    'info' => t('RPX Block Icons'),
    'status' => TRUE,
    'region' => 'sidebar_first',  // Not usually provided.
  );

  return $blocks;
}


/**
* Implements hook_block_view().
*
* This hook generates the contents of the blocks themselves.
*/
function rpx_widgets_block_view($delta = '') {
  //The $delta parameter tells us which block is being requested.
    $block = array();
  switch ($delta) {
    case 'rpx_block_icons':
      $block['subject'] = t('RPX Block Icons');
      $block['content'] = _rpx_widgets_create_block();
      break;
  }
  return $block;
}



function _rpx_widgets_create_block () {
  rpx_js();
  $items = array();
  $realm = variable_get('rpx_realm', '');
  $realm_scheme = variable_get('rpx_realm_scheme', 'http');
  $sign_in_url = "$realm_scheme://$realm/openid/v2/signin";
  $token_url = _rpx_token_url();
  $providers = _rpx_providers();

  // These options are common for all providers.
  $options_template = array(
    'query' => array('token_url' => $token_url),
    'html' => TRUE,
    'attributes' => array(
      'class' => 'rpxnow',
      'onclick' => 'return false;',
      'onmousedown' => 'delete RPXNOW.default_provider;',
    ),
  );

  $icons = '';
  foreach ($providers as $provider_name => $provider_title) {
    $options = $options_template;
    // If it's the first Engage sign-in for the user, this will take them
    // directly to the provider's dialog.
    // @see https://rpxnow.com/docs#sign-in_default_provider
    $options['attributes']['onmousedown'] = "RPXNOW.default_provider = '" . $provider_name . "';";
    $icons .= l(theme('rpx_icon', array('provider' => $provider_name, 'size' => variable_get('rpx_login_icons_size', 'small'))), $sign_in_url, $options);
  }
  $items[] = array(
    'data' => l((variable_get('rpx_signin_string', RPX_SIGNIN_STRING) == '') ? RPX_SIGNIN_STRING : variable_get('rpx_signin_string', RPX_SIGNIN_STRING), $sign_in_url, $options_template) . '<br />' . $icons,
    'class' => array ('rpx-link'),
  );

  $form['rpx_links'] = array(
    '#theme' => 'item_list',
    '#items' => $items,
    '#attributes' => array('class' => array('rpx-links')),
    '#weight' => variable_get('rpx_login_links_weight', 150),
  );

  return $form;   
}

#3

This works for me, but the icons are so TINY. As a workaround I'm using a block with custom PHP that just uses the Engage widgets from their website (script with div). This module really needs some work in terms of block building / ui flexibility. Something like a function that accepts a few arguments and returns some basic html that developers can style with CSS would be just fine with me. Drop that in a block with PHP input style and customize it any way you want.