Today I'd like to discuss a little Drupal 8 snippet to dynamically load an entity from the controller by the current path. This acts a bit like a Drupal 8 replacement for Drupal 7's menu_get_object(). Use case / example:
Drupal CMS
Several times in the last months we had the requirement to prepopulate a Drupal 8 webform with a parent entity ID from the URL. For example we had forms to register for events which we embedded on the node page as paragraphs or blocks and
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
Short snippet to restore product variation assignments (references) in Drupal 8 Commerce after an SQL error has occured on product save, which left product variations orphaned. Fix all product variation relationships having no parent
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
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
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.)
I just had the case to iterate over EntityReferenceRevisionsItem's which are similar to EntityReferenceItem to get the target entities, My code snippet was (WRONG EXAMPLE):
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-…
I've been running into problems with composer several times now in combination with Drupal 8 projects. This blog post shares my problem solving solutions. "Can only install one of ..." when updating In many cases this can be resolved by
This post saved you a lot of time and headache?
Then I'd be very happy about a delicious coffee! Or a helpful book from my wish list.