Skip to content

Instantly share code, notes, and snippets.

View Jako's full-sized avatar

Thomas Jakobi Jako

View GitHub Profile
@bohwaz
bohwaz / php-8.1-strftime.php
Last active March 26, 2024 13:14
strftime() replacement function for PHP 8.1
<?php
namespace PHP81_BC;
/**
* Locale-formatted strftime using \IntlDateFormatter (PHP 8.1 compatible)
* This provides a cross-platform alternative to strftime() for when it will be removed from PHP.
* Note that output can be slightly different between libc sprintf and this function as it is using ICU.
*
* Usage:
* use function \PHP81_BC\strftime;
@rtripault
rtripault / plugin.php
Created January 26, 2017 12:13
Plugin to add a "created by" field on a MODX Revolution resource form, listening on the "OnDocFormPrerender" event
<?php
/**
* Sample plugin to add a "created by" field on a resource form
*
* @var modX $modx
* @var array $scriptProperties
*
* @event OnDocFormPrerender
*/
@frisospeulman
frisospeulman / seoProKeywordConvertor
Last active September 6, 2022 07:36
Converts keyword tv to seoPro Keywords objectCreate a snippet and run it on a blank page.
<?php
/**
* Convert your keyword tv to Sterc's SeoPro
*
* Please read the following.
* Everytime you run this snippet, your keywords within seoPro will be overwritten.
* Make sure the TV exists before runnig this code.
*
*/
$seoPro = $modx->getService('seopro', 'seoPro', $modx->getOption('seopro.core_path', null, $modx->getOption('core_path') . 'components/seopro/') . 'model/seopro/', $scriptProperties);
@herooutoftime
herooutoftime / README.md
Last active May 13, 2022 15:55
MODx (missing) preview of unsaved changes

Idea & Concept

MODx Revolution lacks a preview of unsaved changes. For editors this is a rather important feature to check if their changes are correctly displayed and it's easy to do. No need to unpublish, save and view the resource. Just click 'Preview' and a MODx Window will show you all the changes.

The way it works is pretty easy: When clicking the 'Preview' button and OnBeforeDocFormSave is triggered all current (saved) data will be stored in a cache file, the resource will be saved with the new data. If OnWebPageComplete is fired, the saved data will be replaced with the previously cached data.

So for a short period the actual preview will be live!

Installation

@craigmdennis
craigmdennis / index.html
Last active February 1, 2022 03:08
When not including Modernizr, use this to remove the no-js class from the html.From: http://www.paulirish.com/2009/avoiding-the-fouc-v3/
<html class="no-js">
<head>
<script>(function(H){H.className=H.className.replace(/\bno-js\b/,'js')})(document.documentElement)</script>
</head>
<body>
</body>
</html>
@sepiariver
sepiariver / cbGetLayoutSetting.snippet.php
Last active August 20, 2021 06:16
Gets a ContentBlocks Layout setting.
<?php
/**
* Use the cbGetLayoutSetting snippet to get a setting from a particular layout.
* @author YJ Tso @sepiariver <yj@modx.com>
* @param (id) &resource allows checking for fields on other resources.
* @param (bool) &showDebug return debugging info as JSON.
* @param (string) &toPlaceholder set a placeholder with this string as key, instead of returning.
* @param required (int) &layout - ID of ContentBlocks layout from which to fetch the setting.
* @param required (string) &setting - key of layout setting to return.
*