Skip to content

Instantly share code, notes, and snippets.

@Mark-H
Mark-H / a readme.md
Last active November 24, 2022 13:16
modCli; using MODX on the commandline.

modCLI

modCLI is a wrapper for the MODX Revolution Processors, allowing you to pretty much do anything from the commandline that you would normally do within the manager.

To use modCLI, simply download the modcli.php file and put it in the MODX_BASE_PATH of your installation. Next open up the console or terminal, and start firing some commands at it.

Syntax

@Mark-H
Mark-H / 1. In the ExtJS form declaration.js
Created May 21, 2011 21:53
Fancy MODX / ExtJS combo-box that searches while typing and adds new entries if they don't exist.
// Call the form with the unique xtype
items: [{
xtype: 'campermgmt-newcamper-form-brandscombo',
fieldLabel: 'Merknaam',
name: 'brand',
id: 'brand',
allowBlank: false,
vtype: 'alphanum'
}
<...>
@Mark-H
Mark-H / 1_interface_and_base_class.php
Created March 4, 2015 11:57
Object Oriented Snippets for MODX :D There are a couple of files here. The first one (`1_interface_and_base_class.php`) contains an interface and the base abstract class for creating snippets. The second file (`2_example_snippet.php`) is a real basic example of a snippet. The third file (`3_modSnippet.php`) is the code that is in the actual modS…
<?php
namespace mhwd\Donations;
/**
* Interface ObjectOrientedSnippet
*
* @see Snippet class
*
* @package mhwd\Donations
@Mark-H
Mark-H / gist:3104835
Created July 13, 2012 13:14
Adding transparent watermark to a PhpThumb thumbnail.
{"fltr":{"":"wmi|assets/images/logo-watermark.png|385x220|20|350|58"}}
@Mark-H
Mark-H / plugin.php
Created August 20, 2014 22:24
Auto Login Plugin for MODX Demo Sites. Add to OnManagerLoginFormRender event.
<?php
if ($modx->getOption('http_host') == 'YOUR_DOMAIN_HERE') {
$op = '<script type="text/javascript">
Ext.onReady(function() {
document.getElementById("modx-login-username").value = "USER";
document.getElementById("modx-login-password").value = "PASS";
document.getElementById("modx-login-btn").click();
});
</script>';
@Mark-H
Mark-H / connector.php
Created April 12, 2016 11:10
Connector for MODX Revolution with whitelist of permitted actions accessible from the web
<?php
// set context
$_REQUEST['ctx'] = 'web';
require_once dirname(dirname(dirname(dirname(__FILE__)))).'/config.core.php';
require_once MODX_CORE_PATH.'config/'.MODX_CONFIG_KEY.'.inc.php';
require_once MODX_CONNECTORS_PATH . 'index.php';
// define allowed actions
$webActions = array(
'one/allowed/action',
@Mark-H
Mark-H / chunk.html
Created March 8, 2012 14:11
Plugin to send email notifications to all members of a user group
<p>Hi there!</p>
<p>The resource [[+pagetitle]] (ID: [[+id]]) has been [[+mode]].</p>
<p>You can login to the manager at www.mysite.com/manager/ to review and if needed publish the resource.</p>
<p>Thank you!</p>
@Mark-H
Mark-H / disabletooltips.plugin.php
Last active March 1, 2016 22:15
Plugin to disable tooltips in MODX globally.
<?php
// Disables tooltips globally.
//
// Create a new plugin and add the following system event: OnManagerPageInit
//
// © 2010 Mark Hamstra <hello@markhamstra.com>
// Buy me a beer? Paypal hamstra.mark at gmail.com.
//
// Licensed under the MIT license
@Mark-H
Mark-H / PoweredBy.php
Created January 26, 2016 18:27
MODX X-Powered-By header
<?php
/**
* Add as a plugin
* System Event: OnHandleRequest
*/
if (!headers_sent()) {
header('X-Powered-By: MODX Revolution');
}
@Mark-H
Mark-H / benchmark.php
Created December 7, 2012 17:41
MODX Performance Benchmark Snippet
<?php
// Use this line to prevent people from hammering your server.
if (!isset($_GET['super_secret']) || ($_GET['super_secret'] != 'secretpassword')) return 'Not authorized';
// Call this snippet uncached in a resource with template "empty":
// content: "[[!benchmark]]"
// Make sure to tag the resource as uncachable
// The intro
echo '<body style="font-family: sans-serif;">';