Drupal 7

Drupal 7 Snippet: Photoswipe: Only output first image of image field, but show the rest in swipe gallery

Simple snippet to only output the first image of an imagefield in a view and show the rest of the gallery in the photoswipe overlay.

Hint: Don't forget to add the photoswipe-gallery class on the field wrapper in views settings: http://cgit.drupalcode.org/photoswipe/tree/README.txt?h=7.x-2.x

  1. /**
  2.  * Implements hook_views_pre_render().
  3.  */

Drupal CMS + Google Analytics gaOptOut Datenschutz

Typischerweise wird in Datenschutzerklärungen Deutscher Websites ein JavaScript-Link zum OptOut aus Google Analytics angeboten, wie Websites wie folgende erläutern: https://die-netzialisten.de/wordpress/google-analytics-um-einen-optout-l...

In Kombination mit dem Google Analytics Drupal Modul

Drupal Addressfield Länder Kürzel Liste (z.B. für Feeds Import)

Falls ihr auch einmal Adressen via Feeds importieren möchtet, benötigt ihr für das Land im Addressfield sicher das Länderkürzel.

Nachfolgend findet ihr eine Deutsche Liste der vom Addressfield verwendeten Kürzel, die vermutlich dem ISO Standard entsprechen:

  • AF Afghanistan
  • AL Albanien
  • DZ Algerien
  • UM Amerikanisch-Ozeanien

Drupal hide fieldgroup in HOOK_form_alter

Drupal 7: Ensure HOOK_node_view is not called by search indexing

When using HOOK_node_view() you should take care because when the search (Search API especially) is indexing, this hook is also being called. You can not rely on a user displaying the node display currently. Here's a way to ensure this...

  1. function MYMODULE_node_view($node, $view_mode, $langcode) {
  2.   if ($view_mode != 'full' || arg(0) != 'node') {

Applying and maintaining Drupal patches efficiently

As Drupal developer you have to mess around with patches sometimes. Some of you might use Drupal module to manage their patches, some may use Git. Others may handle patches manually (which is the worst solution).

Einordnung:

Drupal 7 Services 3 Session Authentication with CSRF Token

I really had a bad hour figuring out how Drupal services.module (Version 3.x) session authentication works. The documentation is poor and there are several issues stating out problems.

Finally I was able to find a way out of the Service REST jungle and I'd like to share the results with you (and myself for the future) if we should ever run into the same problems again.

Drupal 7 Commerce: Compare customer profile addresses / check address equality (shipping / billing)

I had the requirement to check the equality of addresses in customer orders (billing / shipping) and wrote two helper functions for that.

Perhaps you'll run into the same demand one day. Then please leave a comment here and in the original issue I posted on Drupal.org to document your demand for such a solution: See https://www.drupal.org/node/2680997

Thank you!

Attach documents (e.g. Terms and conditions) to Drupal Commerce Message order confirmations

Drupal Commerce Message

Attaching documents like PDFs to Drupal eMails is quite simple. For our specific case we needed to attach PDF documents to Drupal Commerce Message order confirmations.

This can easily be done using the hook below. Simply modify the names and path to the document to attach. That's it!

  1. function MY_MODULE_mail_alter(&$message) {

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.module mittels eines Hooks sehr einfach realisiert werden.

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