Tag Archives: Drupal

Drupal 7 – Add the Facebook Connect login button on user registration and login page

In the past 2 days we have talked about the use of Facebook Connect module.
Drupal 7 – Allow Facebook login using Facebook Connect
Drupal 7 – Override the Facebook Connect login button theme

In this post, i will show you how to render the Facebook Login button programmatically in the Drupal user registration and login page.

The following code will render the Facebook Login button programmatically.

$user_profile = fbconnect_user_profile();
$attr = array();
if (variable_get('fbconnect_fast_reg', 0) && variable_get('fbconnect_reg_options', 0)) {
  $attr = array('perms' => 'email');
}
$ss__facebook_connect = fbconnect_render_button($attr);

Continue reading Drupal 7 – Add the Facebook Connect login button on user registration and login page

Drupal 7 – Override the Facebook Connect login button theme

We can implement Facebook Login using Facebook Connect. For more info, please refer to
Drupal 7 – Allow Facebook login using Facebook Connect

For those who wants to override that Facebook Login template, add the following function in your theme template.php and and customize it as u wish.
Continue reading Drupal 7 – Override the Facebook Connect login button theme

Drupal 7 – Allow Facebook login using Facebook Connect

The website i am working now needs to have Facebook Login. I found 3 modules which could implement that feature.

 

Facebook Connect requires the Facebook PHP SDK and the configuration is quite user friendly and this is also the module which i used.

Facebook OAuth provides an API for authentication and does not need the Facebook PHP SDK. It fits for Drupal developesr who wants higher level of customization.

Drupal for Facebook seems to target Facebook application development. I didn’t tried it.
Continue reading Drupal 7 – Allow Facebook login using Facebook Connect

Drupal 7 – Render the Nice Menus programmatically

The following piece of code will print the Nice Menus block.

$menu = theme('nice_menus', array('id' => 1, 'direction' => 'down', 'depth' => 1, 'menu_name' => '<menu-machine-code>', 'menu' => NULL));
print $menu['content'];

 

you can input any value in the <id> parameter and the rendered menu will have the HTML tag id = nice-menu-<id>. Just make sure there is no duplicated nice menu id in the same page.

Done =)

Reference: How to display nice_menus programmatically in Drupal 7

Drupal 7 – Update node programmatically

If you want to update the node programmatically, the following example update the node title and the value of the custom field called field_example.

// Load the node with nid = 1
$nid = 1;
$a_node = node_load($nid);
$a_node->title = 'new title';
$a_node->field_example['und'][0]['value'] = 'new value';

// Save the node
node_save($a_node);

// If you want to populate the node author and creation date, call node_submit() before saving
/*
if($a_node = node_submit($a_node)) {
  // Save the node
  node_save($a_node);
}
*/

 

Done =)

Reference: fooninja.net – Updating nodes programmatically in Drupal 7