Skip to content

Instantly share code, notes, and snippets.

@Mark-H
Mark-H / connector.php
Created Apr 12, 2016
Connector for MODX Revolution with whitelist of permitted actions accessible from the web
View connector.php
<?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 / PoweredBy.php
Created Jan 26, 2016
MODX X-Powered-By header
View PoweredBy.php
<?php
/**
* Add as a plugin
* System Event: OnHandleRequest
*/
if (!headers_sent()) {
header('X-Powered-By: MODX Revolution');
}
@Mark-H
Mark-H / 1_interface_and_base_class.php
Created Mar 4, 2015
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…
View 1_interface_and_base_class.php
<?php
namespace mhwd\Donations;
/**
* Interface ObjectOrientedSnippet
*
* @see Snippet class
*
* @package mhwd\Donations
@Mark-H
Mark-H / plugin.php
Created Aug 20, 2014
Auto Login Plugin for MODX Demo Sites. Add to OnManagerLoginFormRender event.
View plugin.php
<?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 / compare.lexicon.php
Created Jun 19, 2014
compare.lexicon.php - A super useful script for people that want to update translations for MODX (or MODX Extras) and need to get a good at a glance view of the changes. Got it from the forums somewhere in the past, but can't find the original source now. It probably changed a bit over the years too.
View compare.lexicon.php
<?php
$default = realpath(dirname(__FILE__).'/core/lexicon/en').'/';
$local = realpath(dirname(__FILE__).'/core/lexicon/nl').'/';
$showSame = false;
// find default files
$theFiles = array();
if($handle = opendir($default)) {
while(false !== ($file = readdir($handle))) {
@Mark-H
Mark-H / snippet.php
Created Mar 4, 2014
Fix Gallery update to 1.6
View snippet.php
<?php
$modelPath = $modx->getOption('gallery.core_path',null,$modx->getOption('core_path').'components/gallery/').'model/';
$modx->addPackage('gallery',$modelPath);
$manager = $modx->getManager();
$manager->addField('galAlbum', 'year');
@Mark-H
Mark-H / 0_reuse_code.js
Created Feb 3, 2014
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@Mark-H
Mark-H / a readme.md
Last active Mar 4, 2018
modCli; using MODX on the commandline.
View a readme.md

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 / benchmark.php
Created Dec 7, 2012
MODX Performance Benchmark Snippet
View benchmark.php
<?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;">';
@Mark-H
Mark-H / gist:3799296
Created Sep 28, 2012
Change template for @datarecall #modx
View gist:3799296
<?php
$parent = 5;
$resourceWithChildrenTpl = 1;
$resourceWithoutChildrenTpl = 2;
$childs = $modx->getChildIds($parent);
foreach ($modx->getIterator('modResource',array('id:IN' => $childs)) as $resource) {
You can’t perform that action at this time.