Skip to content

Instantly share code, notes, and snippets.

View jenswittmann's full-sized avatar

Jens Wittmann – Gestaltung & Entwicklung jenswittmann

View GitHub Profile
@jenswittmann
jenswittmann / OnAgendaBeforeRemove.php
Last active October 22, 2025 10:21
Prevents booked Cursus dates from being accidentally deleted via the Agenda CMP. See documentation: https://docs.treehillstudio.de/en/agenda/08_System_Events/
<?php
/**
* @package agenda
* @subpackage plugin
*/
namespace TreehillStudio\Agenda\Plugins\Events;
use TreehillStudio\Agenda\Agenda;
@jenswittmann
jenswittmann / video-autoplay.php
Last active October 2, 2025 13:55
HTML5 Video Autoplay in Safari, Chrome und Co. for 2025
<?php if (preg_match('/safari/i', $_SERVER['HTTP_USER_AGENT']) && !preg_match('/chrome/i', $_SERVER['HTTP_USER_AGENT'])): ?>
<!-- Docs: https://developer.apple.com/documentation/webkit/delivering-video-content-for-safari#Use-MP4-Video-Instead-of-Animated-GIFs -->
<img
src="video.mp4"
width="1600"
height="900"
alt="" />
<?php else: ?>
<video
src="video.mp4"
@jenswittmann
jenswittmann / contentblocks-fenom-field-template.example
Last active September 4, 2025 11:37
Use Fenom via pdoTools in ContentBlocks
[[pdoChunk?
&file=`contentblocks/your-chunk-name.chunk.tpl`
&field=`[[+field]]`
&field_type_idx=`[[+field_type_idx]]` ]]
@jenswittmann
jenswittmann / cbdateinput.plugin.php
Last active September 4, 2025 13:15
MODX ContentBlocks Custom Input Date Type Plugin
<?php
if ($modx->event->name == 'ContentBlocks_RegisterInputs') {
class cbDateInput extends cbBaseInput
{
public $defaultIcon = 'snippet_B';
public $defaultTpl = '';
public function getTemplates()
{
@jenswittmann
jenswittmann / babel-extend.plugin.php
Last active August 11, 2025 09:28
Add switch buttons for each language. When deleting a resource, also delete any connected resources via Babel Extra in MODX.
<?php
$eventName = $modx->event->name;
$babelLanguageLinksTv = $modx->getOption('babel.babelTvName');
$connectedResourcesTv = $resource->getTVValue($babelLanguageLinksTv);
// prevent mixedImage hook in via getTVValue()
//$q = $modx->newQuery('modTemplateVarResource', [
// 'tmplvarid' => 20,
// 'contentid' => $modx->resource->id,
//]);
//$q->select('value');
@jenswittmann
jenswittmann / index.css
Created January 23, 2025 10:54
Test File for @modxcms/revolution #16684
/*! normalize-scss | MIT/GPLv2 License | bit.ly/normalize-scss */
/* Document
========================================================================== */
/**
* 1. Correct the line height in all browsers.
* 2. Prevent adjustments of font size after orientation changes in
* IE on Windows Phone and in iOS.
*/
html {
line-height: 1.15; /* 1 */
@jenswittmann
jenswittmann / modx.jsgrps-min.js
Last active December 30, 2024 09:14
Test File for @modxcms/revolution #16667
/*
*
* Copyright (C) 2024 MODX LLC
*
* This file is part of MODX Revolution and was compiled using Grunt.
*
* MODX Revolution is free software: you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation, either version 2 of the
* License, or (at your option) any later version.
*
@jenswittmann
jenswittmann / CurlyRandomGrid.html
Created October 15, 2024 12:49
CurlyRandomGrid
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="utf-8" />
<title>CurlyRandomGrid</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
<style>
.grid {
display: grid;
@jenswittmann
jenswittmann / resizeImage.php
Last active October 22, 2023 11:20
MODX resizeImage Snippet (modern pthumb replacement with srcset generation and very low options, but works on IONOS too)
<?php
# vars
$lib = $modx->getOption("resizeImage_imageLib", null, "cli");
$libPath = $modx->getOption("resizeImage_imageLibPath", null, "/Applications/MAMP/Library/bin/convert");
$mode = $modx->getOption("mode", $scriptProperties, "");
$input = $modx->getOption("input", $scriptProperties, "");
$sizes = $modx->getOption("options", $scriptProperties, "");
$quality = $modx->getOption("quality", $scriptProperties, 70);
$cultureKey = $modx->getOption("cultureKey");
@jenswittmann
jenswittmann / pdf2image.php
Last active October 22, 2023 11:16
MODX pdf2image Snippet
<?php
# vars
$filePath = $modx->getOption('input', $scriptProperties, '');
$savePath = "assets/components/phpthumbof/cache/poster_" . md5($filePath) . ".jpg";
# check file exists and is PDF
if (!file_exists(MODX_BASE_PATH . $filePath) || mime_content_type(MODX_BASE_PATH . $filePath) != "application/pdf") {
return $filePath;
}