Drupal CMS

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 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

Linktipp: Create custom fields in Drupal 8

Guide on how to create custom field types in Drupal 8

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!

Linktipp: Why content type and field in-CMS documentation is more important than any DOCument

Why content type and field in-CMS documentation is more important than any DOCument

The attached article explains detailed why a good documentation within the CMS and talking to the authors is important. Even more important than writing long long documentation documents that nobody ever reads.

It absolutely points out my view in authoring but also in coding purposes. The best documentation is always the documentation that helps in the workflow and not in a separate document.

Drupal 7 Snippet: Add "Cancel" button to Content edit / create forms

Based on the snippet from Pascal Duez:
https://gist.github.com/pascalduez/1888373 (thanks a lot!) I modified a bit, here's a snippet to add a "Cancel" button in Content (Node) create / edit forms.

Simply use your own mini module to implement it.

  1. /**
  2.  * Custom cancel button callback.
  3.  */
  4. function mymodule_form_cancel($form, &$form_state) {
  5.   $fallback_destinaton = '<front>';

Linktipp: Drupal JavaScript Behaviours

Mein heutiger Linktipp dreht sich um JavaScript in Drupal. Genauer gesagt: Drupal.behaviours. Da dieses Thema immer wieder auf den Tisch kommt und häufiger zu Fragen führt, möchte ich den nachfolgenden Artikel zum Thema empfehlen.

Er bietet einen schnellen Einstieg und erläutert fast alles, was man wissen muss. Von attach() bis .once() gibt es ein paar schöne Dinge zu lernen :)

Drupal 7 Migrate Module: Migration not working with result "Processed 0 (0 created, 0 updated, 0 failed, 0 ignored)" even if there are entries to process

Some days ago I had to program a bigger import for a Drupal 7 Forum, including several hundreds of thousands of entries and comments. I decided to use the Drupal migrate.module as helper for this import and it was a good decision!

migrate.module made things much easier and reduced the amount of custom import code.