Skip to content

Instantly share code, notes, and snippets.

@enminc
enminc / modx.batchDeleteUnwantedUsers.php
Created October 2, 2013 06:16
simple modx api script to remove unwanted users
$dontRem = array('adam','admin'); /* add any additional context you dont wish to have removed here */
$users = $modx->getCollection('modUser');
foreach($users as $user){
$id = $user->get('id');
$name = $user->get('username');
if(!in_array($name,$dontRem)) {
$response = $modx->runProcessor('security/user/delete',array('id'=>$id));
if ($response->isError()) {
echo $response->getMessage() . '<hr/>';
@replete
replete / _block-grid-5-custom.scss
Created September 14, 2013 12:03
I've re-aligned Zurb 4.3/5's (mainly adds 'medium') grid and block-grid to activate with corresponding media query breakpoints. See my full post at https://github.com/zurb/foundation/issues/3261
// I've updated the Zurb4.3/5 Grid/block-grid systems to be in line with my suggestions at https://github.com/zurb/foundation/issues/3261
// http://github.com/replete
//
// Block Grid Variables
//
$include-html-grid-classes: $include-html-classes !default;
// We use this to control the maximum number of block grid elements per row
$block-grid-elements: 12 !default;
@jpdevries
jpdevries / gist:5923886
Created July 3, 2013 23:56
Dynamically set current user's redactor.image_upload_path Setting based on the alias of the currently edited resource's parent
<?php
switch ($modx->event->name) {
case 'OnDocFormPrerender':
if(!$resource) return;
$key = 'redactor.image_upload_path';
$userId = $modx->user->get('id');
$usersetting = $modx->getObject('modUserSetting', array('key' => $key, 'user' => $userId));
if(!$usersetting) return;
@jpdevries
jpdevries / gist:5516772
Last active December 16, 2015 23:50
Using phpthumb in a MODX CMP
$modAuth = $this->modx->user->getUserToken('mgr');
$thumbQuery = http_build_query(array(
'src' => $image['urlAbsolute'],
'w' => 360,
'h' => 270,
'HTTP_MODAUTH' => $modAuth,
//'f' => $thumbnailType,
'q' => 80,
'wctx' => 'mgr',

Website Contract

Revised date: 13/03/2013

Between us: Crunch Design

and you: [customer name]

Summary:

@MikeRogers0
MikeRogers0 / twitter-proxy.php
Last active June 3, 2019 12:56
This is a neat little script you can use to quickly make OAuth requests to the twitter rest API v1.1.
<?php
/**
* Usage:
* Send the url you want to access url encoded in the url paramater, for example (This is with JS):
* /twitter-proxy.php?url='+encodeURIComponent('statuses/user_timeline.json?screen_name=MikeRogers0&count=2')
*/
// The tokens, keys and secrets from the app you created at https://dev.twitter.com/apps
$config = array(
@christianseel
christianseel / modxcloud nginx web rules
Last active March 31, 2016 20:32
# x-ua-xompatible # expire headers for assets # www.mydomain.com -> mydomain.com # filename-based cache busting # trailing slash redirect # statcache rewrite # modx furls rewrite
# x-ua-xompatible header
add_header X-UA-Compatible IE=edge,chrome=1;
#default charset uft-8
charset utf-8;
# allowed domains
set $rewrite_var 0;
@jpdevries
jpdevries / gist:4684764
Created January 31, 2013 17:49
example of manually coded main nav in MODX as opposed to using wayfinder for everything
<header>
<a href="[[++site_url]]" class="logo">Heart Coffee Roasters</a>
<nav class="primary">
<ul>
<li class="home"><a href="[[++site_url]]">Home</a></li>
<li class="about">
<a class="tap-touch " href="[[~12? &scheme=`full`]]">About<span class="extra"> Heart</span></a>
<div class="dropdown-mask">
<div class="dropdown">
<ul>
@mkschell
mkschell / babelContextRouter.plugin.php
Last active October 19, 2023 07:08
MODX Cloud web rules example for Babel with two languages.In this example, German is the default language with resources in the 'web' context; English is the secondary language, set up in the 'en' context.This technique is based on the "SEO Friendly Multilingual Websites" article archived here: https://web.archive.org/web/20180927220103/http://w…
<?php
if($modx->context->get('key') != "mgr"){
/* grab the current langauge from the cultureKey request var */
switch ($_REQUEST['cultureKey']) {
case 'en':
/* switch the context */
$modx->switchContext('en');
break;
default:
/* Set the default context here */
@gnab
gnab / find-that-bastard.js
Created September 14, 2012 11:46
Find the event handler blocking events (event.preventDefault())
// Scenario: Some event handler is blocking events (event.preventDefault()) that shouldn't be blocked, i.e. because it binds to document instead of a more specific element
// 1) Place this before all other JavaScript
var originalPreventDefault = Event.prototype.preventDefault;
Event.prototype.preventDefault = function () {
// Lookup specific event you're expecting, i.e. pressing space
if (this instanceof KeyboardEvent && this.keyCode === 32) {
// This will log an error with full stack trace
make_error_to_see_stacktrace