Drupal

Drupal 8 views set exposed filter (default) programatically with auto-submit

Setting a dynamic views exposed filter can be done via hook_form_FORM_ID_alter() regularly if it's just a prepopulation of the views exposed filter form.

But if you wish to immediately run the filters using better_exposed_filters auto-submit when the view is loaded you have to use hook hook_views_pre_build(). Otherwise setting the #default_value is just too late.

Use the following code:

Einordnung:

Drupal 8 Field Type Schema column add / change / delete HOOK_update

As heavily discucced in this years old issue: [#937442] there isn't a good solution or helper in Drupal core currently to change the schema of a custom field.

Modules like

  • field_collection
  • dynamic_entity_reference (#51)
  • address
  • viewsreference
  • ...

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 7 Snippet: Add lightbox fallback for image_link_formatter

Little Drupal 7 snippet for the image_link_formatter module (https://www.drupal.org/project/image_link_formatter) to add a fallback to lightbox in size large if no link is given.
Should work the same with other fallbacks (colorbox, etc.).

With some time you could create a clean field formatter from this containing the hard coded values as field display settings.

  1. /**

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

Linktipp: Create custom fields in Drupal 8

Guide on how to create custom field types in Drupal 8

Drupal 8 Entity reference blocks: restricted access (Eingeschränkter Zugriff)

You're referencing a Drupal 8 block via block reference but after saving the entity reference input field says "restricted access" (German: "Eingeschränkter Zugriff")? That's simple to solve... and "works as designed".

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!