Drupal

Dokumente (z.B. AGB,WRB) an Drupal Commerce Bestellbestätigungen anhängen

Drupal Commerce Message attachments

Deutsche Onlineshops / eCommerce-Seiten müssen in der Regel AGB und WRB per E-Mail an Kunden versenden. Dies kann unter Einsatz des ‎Commerce Message‎ mittels eines Hooks sehr einfach realisiert werden.

So lassen sich Dokumente ganz einfach an ‎Commerce Message‎ Bestellbestätigungen z.B. als PDF anhängen. Natürlich funktioniert dies auch für beliebige andere Dokumenttypen.

Snippet: Drupal 7 render view in code and hide if empty results

Use this simple snippet to embed a view in code and only display it if the view has at least one result (prevent rendering empty views markup):

  1. $view = views_get_view('your_view_name');
  2. $view->set_display('your_view_display');
  3. // Only display the view if it has results and the user has access.
  4. if ($view->access('your_view_display')) {        
  5.         // Example argument

Define extra fields (display) in code for Drupal Commerce products with auto AJAX handling and product+product node types handling

Today I had the challenge to add some extra (programatically calculated) fields to show in ‎Drupal Commerce‎ product display nodes. In our specific case it was a "base price" that should be shown additionally to calculated SALE prices.

Drupal 7 Snippet: Add first level menu item mlid as body class for sectionizing your pages

If you'd like to separate your website areas by main menu first levels (for example colourize all areas in a different colour) a body class outputting the first level mlid may help you (otherwise you can for example use ‎Context‎ or things like that!):

Here's the snippet you may use:

  1. function YOUR_THEME_preprocess_html(&$variables, $hook) {

Drupal 7 E-Mail Ausgabe debuggen / protokollieren mit DevelMailLog

Heute möchte ich Euch in einem kurzen HowTo zeigen, wie ihr E-Mails aus Drupal ganz einfach mithilfe des Moduls ‎Devel‎ und ‎Mail System‎ (oder einer settings.php Konfigurationseinstellung) abfangen und den Quellcode debuggen könnt.

Linktipp: Great blog post about Drupals entity_metadata_wrapper

Just WHAO! You should read it :)
I've been using them for a long period of time already but there were some still things to learn!

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

Today I'd like to provide you with a little ‎Drupal Commerce‎ 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‎ inkl. Sprachumschaltung auf Deutsch für die Rechtschreibprüfung (Standard-Sprache)

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' => '...',