Skip to content

Instantly share code, notes, and snippets.

christianseel / MODX index.php
Created June 28, 2017 15:35
MODX index.php with XRouting integrated
* This file is part of MODX Revolution.
* Copyright (c) MODX, LLC. All Rights Reserved.
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
christianseel / modParsedManagerController
Created April 14, 2016 07:48
save at core/components/<yournamespace>/controllers/<alias>.class.php and call it via /manager/?a=<alias>&namespace=<yournamespace> (make sure to add the namespace to you namespaces in MODX) –
class TestcmpParsedManagerController extends modParsedManagerController
public function getPageTitle() {
return 'Test CMP';
public function process(array $scriptProperties = [])
christianseel / regClient.snippet.php
Last active February 2, 2016 12:54
Usage: [[!regClient? &input=`markup or script here` &function=`htmlToBottom`]]
$options = isset($options) ? $options : 'htmlToBottom';
$function = $modx->getOption('function', $scriptProperties, $options);
$plaintext = (strstr($input, PHP_EOL)) ? true : false;
switch ($function) {
case 'cssToHead':
case 'htmlToHead':
christianseel / alfred_sipgate
Last active May 15, 2016 21:18
AppleScript for for Sipage. You need to be logged in at at the same time
on alfred_script(q)
tell application "Google Chrome"
set ActivePage to window 1
set CallTab to make new tab at end of tabs of ActivePage
set URL of CallTab to ""
delay 1
set jscode to "function post(path, params, method) { method = method || 'post'; var form = document.createElement('form'); form.setAttribute('method', method); form.setAttribute('action', path); for(var key in params) { if(params.hasOwnProperty(key)) { var hiddenField = document.createElement('input'); hiddenField.setAttribute('type', 'hidden'); hiddenField.setAttribute('name', key); hiddenField.setAttribute('value', params[key]); form.appendChild(hiddenField); } } document.body.appendChild(form); form.submit(); } post('', {from: '2373479e0', to: '" & q & "'});"
execute front window's active tab javascript jscode
delay 1
christianseel / extract-teaser-layouts.php
Last active May 6, 2016 09:36
MODX Plugin (OnDocFormSave): Extract Teaser Layouts – saves a specific ContentBlocks layout into a TV to make it available elsewhere. To prevent the layout from rendering in the content area you need to wrap your CB layout template into [[+render_teaser:is=`1`:then=`<template here>`:else``]]
// load service
$corePath = $modx->getOption('contentblocks.core_path', null, $modx->getOption('core_path').'components/contentblocks/');
$ContentBlocks = $modx->getService('contentblocks','ContentBlocks', $corePath.'model/contentblocks/');
// get cb json
if ($modx->event->name == 'OnDocFormSave') {
$cbJson = $resource->get('contentblocks');
} else {
$cbJson = $resource->getProperty('content','contentblocks','');
christianseel / fix-file-permissions
Created March 13, 2015 14:07
fix file and folder permissions for MODX
switch($modx->event->name) {
case 'OnFileManagerDirCreate':
$modx->log(modX::LOG_LEVEL_ERROR, 'fix folder permissions for: '.$directory.'/');
chmod($directory.'/', octdec($modx->getOption('new_folder_permissions')));
case 'OnFileManagerFileCreate':
$modx->log(modX::LOG_LEVEL_ERROR, 'fix file permissions for: '.$path);
chmod($path, octdec($modx->getOption('new_file_permissions')));
christianseel / XRouting 1.3.1
Created January 20, 2015 14:43
XRouting 1.3.1 (with debug info: add ?xrdebug=1 to your URL)
switch ($modx->event->name) {
// "refresh cache" part
case 'OnContextSave':
case 'OnContextRemove':
case 'OnSiteRefresh':
$contexts = array();
$cacheKey = 'xrouting_contextmap';
<script type="text/javascript">
(function () {
"use strict";
// once cached, the css file is stored on the client forever unless
// the URL below is changed. Any change will invalidate the cache
var css_href = './index_files/web-fonts.css';
// a simple event handler wrapper
function on(el, ev, callback) {
if (el.addEventListener) {
el.addEventListener(ev, callback, false);
christianseel / gist:9ef49c1a2f225c337909
Created October 5, 2014 16:45
Replace ContentBlocks values with new values
$c = $modx->newQuery('modResource');
$resources = $modx->getCollection('modResource', $c);
foreach ($resources as $res) {
$properties = $res->getProperties('contentblocks');
if (empty($properties)) continue;
if (empty($properties['content'])) continue;
christianseel / Chunk tabNavigationItem
Last active November 8, 2023 11:47
"generateTabs" output filter for ContentBlocks. See for instructions.
<li class="tab-title [[+idx:is=`1`:then=`active`:else=``]]" role="presentational">
<a href="#[[+id]]" role="tab" tabindex="0" aria-selected="false" controls="[[+id]]">[[+title]]</a>