Tag Archives: Drupal 7

Drupal 7 – Simple Ajax implementation @ 1

In this post, i will show you how to implement a simple Ajax function in Drupal 7. The following example code is based on the blog post written by Kevin Hankens about implementing Ajax in Drupal 6.
Kevin Hankens’s blog – Drupal, jQuery and $.ajax() easyness

What i am going to do is the same as Kevin’s example. But for simplicity, i removed the access control logic so all content is visible to anonymous users.
Continue reading Drupal 7 – Simple Ajax implementation @ 1

Drupal 7 – Legal module error – Notice: Undefined variable: accepted in legal_form_user_profile_form_alter()

The stable release of the Legal module has so many errors. But this one is also found in the dev release.

This error this time is
Notice: Undefined variable: accepted in legal_form_user_profile_form_alter()…
Continue reading Drupal 7 – Legal module error – Notice: Undefined variable: accepted in legal_form_user_profile_form_alter()

Drupal 7 – Legal module error – array_flip() [function.array-flip]: Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load()

If you meet the following error of the Legal module.
Notice: Undefined variable: options in views_handler_field_locale_language->render()…
 
Continue reading Drupal 7 – Legal module error – array_flip() [function.array-flip]: Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load()

Drupal 7 – Create your own Rules event

Update @ 2012-10-25: Please make sure you have the PHP filter module enabled. Thanks Beneto.

The Rules module is must have module for developers who needs to deal with some workflow features. Basically each rule contains 3 parts.

  • Event
  • Condition
  • Action

By default the Rules module already provides some basic events, conditions and actions. But some times we may want to create custom components. For me, the most critical part is create a custom event which i would like to show in this post. For the other two, it is less important because the default components already include Execute custom PHP code. That means even without custom module, i could still do whatever i want in Condition and Action.
Continue reading Drupal 7 – Create your own Rules event

Drupal 7 – Reference field option limit for hierarchy taxonomy

Update @ 2013-11-28: You can also consider using Taxonomy Term Reference Tree Widget suggested by kenorb. =D

When you have a hierarchy structure of taxonomy, the default selection list is not quite user friendly because it list out all the parent and child terms. Assume with want to attach a country and city terms to the Article content type. The most straight forward way is create one vocabulary with some countries as parent terms and some cities as child terms like the following list.
  — England
    — London
    — Manchester
  — France
    — Lyon
    — Paris

It turns on that when someone is adding a new article, he may select either a country term or a city term. That is probably not what we want.
Continue reading Drupal 7 – Reference field option limit for hierarchy taxonomy

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