Snippet

Snippet: Drupal 8 Commerce: Show SKU in product variation inline entity form table

Before our modifications to the IEF table

Today I'd like to share a little snippet with you on how to add or remove fields from the inline entity form line items table in a product edit form.

By default that inline entity form table contains

  • Weight
  • Product variation title
  • Price
  • Status
  • Operations

What we'd like to do in our example is to

JTL Artikel pro Seite Limit 100 Maximum übersteuern (Suche / Kategorien)

Heute ein kleiner Tipp für Anwender von JTL-Shop 3 und JTL-Shop 4:

Drupal 8: Load current entity from controller dynamically *updated*

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:

VSCode (Visual Studio code) mark dollar sign $ on double click

Visual Studio Code is my new IDE love. It's simple, lightweight but brings great functionality.

One little problem was that when double-clicking a variable with a dollar-sighn ("$") (for example in PHP or JavaScript) not the whole $variable was marked, but only the text without the $.

JTL-Shop 4: AJAX events / hooks / bindings "contentLoaded"

Ein typisches Problem im Umgang mit AJAX ist die (re-)Initialisierung von Scripts auf den nachträglich geladenen Inhalt. Im JTL-Shop 4 stößt man darauf beispielsweise auf Kategorieübersichten bei der Seitennavigation.

Viele Systeme, viele Lösungen

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 8: Looping through EntityReferenceItem(s) / EntityReferenceRevisionsItem(s) to get Target Entities is wrong

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

  1. $subParagraphsER = $paragraph->get('field_paragraphs_paragraphs');
  2. foreach ($subParagraphsER as $subParagraph) {
  3. ...
  4. }

JTL-Shop4: SSL / https via Datenbank deaktivieren (Migration)

Heute ein kleiner Tipp für JTL-Shop4 Administratoren: Falls ihr im Rahmen einer Migration die Einstellung für SSL direkt in der Datenbank (+ ggf. .htaccess bedenkden!) deaktivieren müsst, geht das mit folgendem Befehl:


UPDATE `teinstellungen` SET cWert = 'N' WHERE `cName` LIKE 'kaufabwicklung_ssl_nutzen'

Der Wert für "Permanent" ist hier z.B. "P".