Snippet: Drupal Commerce: Hide subtotal (DE: "Zwischensumme") in commerce_price_formatted_components

  1. /**
  2.  * Implements HOOK_preprocess_commerce_price_formatted_components
  3.  */
  4. function YOUR_MODULE_preprocess_commerce_price_formatted_components(&$variables) {
  5.   // Do not show the subtotal (Zwischensumme) in components table
  6.   if (!empty($variables['components']['base_price'])) {
  7.     unset($variables['components']['base_price']);
  8.   }
  9. }

Drupal Commerce: Determine currently selected product variation (or default delta)

Today I'd like to provide you with a little commerce.module snippet to determine the currently selected product variation (using commerce_product_reference.module) of a product display with several variations.

I had to search hard for it so here's the code for you:

  1. // Determine the currently selected product or default product for this product display

Drupal: WYSIWYG + CKEditor + Live-Rechtschreibprüfung via scayt aktivieren und Sprache auf Deutsch einstellen

Heute ein kleines Drupal Modul-Snippet zur Aktivierung der autom. Rechtschreibprüfung via Scayt im CKEditor unter Einsatz des wysiwyg.module inkl. Sprachumschaltung auf Deutsch für die Rechtschreibprüfung (Standard-Sprache)

Snippet: JavaScript: Create css class/id/name identifier cleanly from string

Based on!!
this simple JavaScript snippets turns strings into valid HTML id / class / name identifiers (


Using drush and aliases.drushrc.php with non-standard SSH-Port

Drupal Drush aliases.drushrc.php for setting SSH remote port

Today I'd like to give you a little hint how to a execute a remote SSH drush command successfully for a connection defined in aliases.drushrc.php when the SSH port differs from default "22". This is for example the case on Hetzner Hosting.

In my case I set the "remote-port" option, but with no success:

  1. $aliases['live'] = array(
  2.   'remote-host' => '...',

Drupal 7 Developer Snippet: Embed a minipanel in Code in Drupal 7 using contexts

Not much more to say... :)

  1. ctools_include('context');
  2. $panel_mini = panels_mini_load('my_minipanel_machinename');
  4. // In this example the mini panel has two contexts: A displayed user argument (required) and the current logged in user.
  5.   $displayed_user_context = ctools_context_create('entity:user', $displayed_user);
  6.   $user_context = ctools_context_create('entity:user', $user);

Drupal subscriptions.module: Exclude (current) user from notifications about own changes via HOOK

With the following little HOOK snippet you can exclude users from receiving notifications about own changes in the subscriptions.module:

  1. /**
  2.  * Implements HOOK_subscriptions_queue_alter.
  3.  */
  4. function MYMODULE_subscriptions_queue_alter(&$event){
  5.   global $user;
  6.   if(!empty($user)){
  7.     // Prevent users from receiving notifications about own changes.

Drupal 7 set JavaScript / jQuery trigger on autocomplete field option

With this little snippet you can easily set a trigger on autocomplete field options (suggestions) click:

  1. $(document).on('click', 'div.reference-autocomplete', function(e) {
  2.   // Do what you need to do ;)
  3. });

It's not that easy because the selection click does not trigger any change event on the parent input.

Solution to: Call to undefined function node_form_validate on ajax form submit

If you're running into the JavaScript alert error message on creating an AJAXified node form:

Call to undefined function node_form_validate() ...

... the reason might be that the $form_states array contains wrong information which files to load on form build.

Drupal 7 API: Trigger views AJAX refresh via JavaScript or from PHP using ajax_command_invoke

Drupal 7 views.module allows to refresh ajaxified views
dynamically via a javascript call.

Implementation in JavaScript

The JavaScript call is simple:

  1.   jQuery('.view-id-XXX').trigger('RefreshView');

Implementation in PHP