Skip to content

Instantly share code, notes, and snippets.

@matdave
matdave / imageRotate.2.x.plugin.php
Last active October 2, 2023 07:35
MODX imageRotate Plugin
<?php
// run plugin OnFileManagerUpload
switch ($modx->event->name) {
case "OnFileManagerUpload":
if(!empty($files)){
foreach($files as $file){
if ($file['type'] != "image/jpeg" && $file['type'] != "image/png")
return;
// max number of pixels wide or high
$max_image_dimension = $modx->getOption('max_image_dimension',$scriptProperties,0);
@matdave
matdave / codeSample.snippet.php
Last active April 10, 2020 16:24
MODX codeSamples
<?php
/**
* codeSample Snippet for rendering ASCII characters of element calls in MODX frontend
* e.g.
* [[codeSample?&element=`QuickEmail`&properties=`debug=1` &cachedFlag=`true`]]
* outputs [[!QuickEmail? &debug=`1`]]
**/
$element = $modx->getOption('element', $scriptProperties, null);
$type = $modx->getOption('elementClass', $scriptProperties, 'modSnippet');
@matdave
matdave / recaptchav3.post.snippet.php
Last active April 14, 2020 22:36
MODX reCaptchaV3 POST
<?php
/**
* recaptchav3 POST Validator for use with MODX form processors
*
* Based on https://github.com/google/recaptcha
*
* @copyright Copyright (c) 2014, Google Inc.
* @link http://www.google.com/recaptcha
*
* Ported to MODX by YJ Tso @sepiariver
@matdave
matdave / createdBy.plugin.php
Created August 12, 2020 21:05
MODX change author plugin
<?php
/**
* Plugin to add a "created by" field on a resource form and moves "published on" to document tab
*
* @var modX $modx
* @var array $scriptProperties
*
* @event OnDocFormPrerender
*/
$dateFormat = $modx->getOption('manager_date_format',null,'d.m.Y');
@matdave
matdave / modx_site_structure_pretty.sql
Last active October 8, 2024 16:56
MODX count number of times a template is used
SELECT a.id AS 'ID',
CASE
WHEN a.menutitle = '' THEN a.pagetitle
ELSE a.menutitle
END AS 'Title',
a.uri AS 'URI',
c.templatename AS 'Template',
CASE
WHEN a.hidemenu = 1 THEN 'Hidden'
ELSE 'Visible'
@matdave
matdave / Shadow of the Ninja (USA).cht
Created January 15, 2021 19:41
Shadow of the Ninja Cheats
SCf55d:a5:c6:Infinite continues
SCac6d:2c:9d:Don't lose energy from enemy attacks
SC9564:00:04:Don't lose energy from falling
SC8c19:10:04:Maximum energy gained from potion
SC8c31:28:14:40 throwing stars on pick-up
SC8c46:14:05:20 bombs on pick-up
@matdave
matdave / Creative One Page Theme.template.html
Created January 27, 2021 21:23
Fred (Creative One Page Theme)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="">
@matdave
matdave / bulkChange.snippet.php
Created February 9, 2021 16:12
bulkChange Snippet for MODX
<?php
// Choose the Parent ID for the bulk changes
$parent = 12393;
// Set how deep we want to search into sub-pages
$depth = 3;
// Grab all the IDs
$children = $modx->getChildIds($parent, $depth, array('context' => 'web'));
if(!empty($children)){
@matdave
matdave / showUrl.plugin.php
Last active March 5, 2021 17:09
showUrl MODX
<?php
/**
* Plugin to add a read only "url" field to the document tab
*
* @var modX $modx
* @var array $scriptProperties
*
* @event OnDocFormPrerender
*/
if(!$resource || !$mode || $modx == "new") return;
@matdave
matdave / evo2revo.site_content.sql
Last active December 13, 2022 18:07
Evo to Revo
SELECT id, type, pagetitle, longtitle, description, alias, alias_visible, link_attributes, published, pub_date, unpub_date, parent, isfolder, introtext, content, richtext, template, menuindex, searchable, cacheable, createdby, createdon, editedby, editedon, deleted, deletedon, deletedby, publishedon, publishedby, menutitle, donthit, privateweb, privatemgr, content_dispo, hidemenu, 'MODX\\Revolution\\modDocument' AS class_key, 'web' AS context_key, 1 AS content_type, null AS uri, 0 AS uri_override, 0 AS hide_children_in_tree, 1 AS show_in_tree, null AS properties FROM `modx_site_content`