Snippets
An dieser Stelle können von mir im Blog veröffentlichte oder verlinkte Code Snippets zentral gefunden werden.
PHP DOMDocument UTF-8 data into ISO-8859-1 document snippets
Encoding is hard in many cases. Today I ran into one, where we had to save UTF-8 data (from a Drupal website) into an XML document which requires ISO-8859-1 encoding.
We're using https://www.php.net/manual/de/class.domdocument.php for that, which seems to have some problems / flaws with such cases, as the following issues show:
Run Jira Server on Hetzner Managed vServer
Szenario
Wir wollen testen, ob das beliebte Atlassian Jira auch auf einem Hetzner Managed Server betrieben werden kann.
Um das Leistungs-Minimum zu testen, haben wir uns für einen VSERVER MC40 entschieden.
Vorarbeiten
Drupal 8: Add menu item with anchor link programmatically in .menu.yml
For a Drupal 8 EU Cookie Compliance patch I needed a way to add an anchor link as default menu item programmatically in .menu.yml
example.anchor:
title: "Anchor example"
description: "Scroll to top on the current page"
url: "internal:#top"
Shopware 5 - defekte Varianten entfernen
Es kann in Shopware 5 aufgrund fehlender Validierung im Import / Export passieren, dass "defekte" Varianten angelegt werden. Also Varianten, denen die korrekte Zuordnung zu ihrem Elternartikel fehlt.
Drupal 8: Add field validation constraint programmatically
In foundation_anchor_menu_block module I needed to add a validation to a field in a block to ensure the entered value matches the regex allowed for an "id" HTML element attribute.
Drupal 8: Delete view programmatically
If you should run into the same situation, that you'd like to delete a view programmatically, for example on module uninstall, here you go:
- \Drupal::service('config.factory')->getEditable('views.view.' . $view_name)->delete();
Using wget for Cronjob without output
Short snippet to use for a cronjob to call a url if you don't want any output:
* * * * * /usr/bin/wget wget -qO /dev/null https://www.example.com/your-script-to-run
Or to only use HEAD:
* * * * * /usr/bin/wget wget --spider -qO /dev/null https://www.example.com/your-script-to-run
For further details see https://www.gnu.org/software/wget/manual/wget.html
Download PDFs in Cordova InAppBrowser (3.1.0)
I wasted several hours on handling PDF downloads in cordovas inAppBrowser.
My situation was that a page was loaded in inAppBrowser which contained links to PDF Downloads from the same host.
The links simply didn't work.
JTL-Shop 4 "keinBild.gif" Platzhalter Grafik updatesicher ersetzen / überschreiben
Heute ein kleiner Tipp für JTL-Shop Entwickler: Wenn ihr die Platzhalter-Grafik für "Kein Bild vorhanden", z.B. für Kategorien, Produktbilder o.Ä. kundenspezfisch und updatesicher durch Grafiken aus Eurem JTL-Shop Template ersetzen möchtet, könnt ihr dies durch folgende Einträge in der Konfiguration erzielen (Beispiel):
Drupal 8 print current breadcrumb trail with route title
Whao, that wasn't as easy as I thought. I wanted to print out the two top level breadcrumb elements, without "Home", with node title in a custom block. I tried it in many different ways but ran into surprises every time. So finally I'd like to share my code with you, if you should run into the same situation:
Julian Pustkuchen, M. Sc. Wirtschaftsinformatik ist passionierter Software- & Webentwickler mit den Schwerpunkten Softwaredesign, Objektorientierung sowie Usability- & Ablaufoptimierung bei webks. Ein weiterer Schwerpunkt ist die Entwicklung im CMS Drupal.
Entwickelt Julian gerade keine Software, fährt er Ski, Mountainbike, spielt Badminton, segelt oder verbringt Zeit mit Freunden.
Dieser Blog dient als sein "öffentlicher Notizblo(ck/g)".
Webbasierte Lösungen? Machen wir!
webks: websolutions kept simple
http://www.webks.de
Dir hat dieser Beitrag viel Zeit und Nerven gespart?
Dann freue ich mich über jede kleine Anerkennung:
Oder du suchst weitere professionelle Unterstützung?
Dann bietet dir unser webks.de Softwareentwickler-Team professionelle Dienstleistungen im Web-Development und der Drupal CMS Entwicklung!