I am having trouble getting hook_form_alter() to override the position of the Gigya Login Block element in either user_login or user_login_form. Before we had a stable release, I did this simply by hacking the code. But now that the module is stable, I didn't want to fork the code, so now I am trying to do it in the custom module I use for my site's customizations.

I have reviewed http://www.lullabot.com/articles/modifying-forms-drupal-5-and-6 and I can create a theme function called um_user_login() in my custom theme (called "um"). I made a modification to theme_gigya_login_block, in my theme, so that it wouldn't include the JS code a second time, since I thought that might be causing issues.

It seems like the #prefix element shows up on the page even after I have unset it in my theming function. On the other hand, I don't consistently see it in the $form array, even when I haven't unset it. This is very puzzling, to say the least.

I have given up on trying to theme the form the "right" way now, and am just going to do it in the actual module code. It would be great if azinck or someone else could figure out what I'm doing wrong though, so that I won't have to continue with a forked version of the module.

Below is the code from my template.php:


function um_gigya_login_block($form_id = NULL, $suppress_title = TRUE, $add_js = TRUE) {
   if ($add_js == TRUE) {
    gigya_login_block_js();
    $login_js = 'Drupal.behaviors.gigya_login = function(context){ Drupal.gigya.login(); }';
    drupal_add_js($login_js, 'inline');
  }

  if (!$suppress_title) {
    $title = t('Login using social networks');
    $output = '<h2>'. $title .'</h2>';
  }
  else {
    $output = '';
  }
  
    $output .= '<div class="gigya-login"><div id="'. variable_get('gigya_login_uiconfig_containerID', GIGYA_DEFAULT_LOGINUI_CONTAINERID) .'"></div></div>'; 
			
  return $output;
}

function um_user_login($form) {
	$form['#suffix'] .= '<div class="use-text"> or use </div>' . theme('gigya_login_block', 'user_login', TRUE, FALSE);    
	unset($form['#prefix']);
	$output = '';
	$output .= drupal_render($form);
	return $output;
}

CommentFileSizeAuthor
#1 gigya-login-settings.patch4.41 KBEvanDonovan

Comments

EvanDonovan’s picture

Title: What is the best way to override the positioning of the Gigya Login Block? » Add options to admin UI for overriding positioning & hide title of Gigya Login Block
Category: support » task
Status: Active » Needs review
StatusFileSize
new4.41 KB

azinck:

As per our conversation of today, regarding how it seems to be impossible, or at least not simple, to override this in the theme layer, I am submitting a patch to add options for controlling whether the Gigya login block appears at the top or the bottom of the login forms, and whether it has a title or not. There's also some minor code style changes in it, if that's OK.

These are the two settings that I think people will most often want to change, and thus should be in the admin UI.

If you have any questions about the patch, please add them to this issue.

If you think the code style could be better, feel free to do it in your own way. I do think some functionality like this is necessary, though. I will be running a forked version of the module, until this or an analogous feature is committed.

Note: this patch was rolled from the directory above the gigya module, as diff -urp gigya_old gigya > patch-name.patch. (I couldn't do CVS diff because for some reason, my work server can't correctly checkout from Drupal CVS.) The patch applied for me from inside the gigya directory when I tested it. Let me know if you have issues.

azinck’s picture

Status: Needs review » Fixed

committed to dev

EvanDonovan’s picture

Thanks so much!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.