Skip to content

Instantly share code, notes, and snippets.

@enminc
enminc / vcGetProductCustomField-rc4Fix
Created June 28, 2011 17:53
Temporary Fix for VisionCart "vcGetProductCustomField" Snippet. The changes to this snippet have been logged in big tracker
<?php
/**
* @package visioncart
*/
$vc =& $modx->visioncart;
# !!! FIXED: Fixed statement to be !isset rather then isset
#####################################################
if (!isset($scriptProperties['id']) || !is_numeric($scriptProperties['id'])) {
@enminc
enminc / galleryRedirector.modx.plugin.php
Created January 6, 2012 04:55
Quick and dirty query sting redirector
/*
Quick plugin I just wrote to redirect querystring based uri's used in old site to new modx resource location.
Not intended to be anything more then a quick fix until search engines are no longer indexing the old links.
Might be useful in helping someone learn how to write a dynamic 301 redirect
*/
/*
NOTE: For a more robust controller I would recommend you checkout http://modx.com/extras/package/simplxcontroller by larscwallin
*/
@enminc
enminc / snippet.rand.php
Created January 26, 2012 02:13
MODX Snippet/OutputFilter that outputs the results of php rand() function
$min = 0;
$max = 10000000;
$input = $modx->getOption('input',$scriptProperties,null);
if(($input) && ($input != '')){ // used when used as output filter
$nums = explode(',',$input);
if($nums[0] != '' && is_numeric($nums[0])){
$min = intval($nums[0]);
}
@enminc
enminc / indexer.plugin.php
Created February 23, 2012 06:36
MODX Revo indexer plugin. Allows fast TV filter searches using custom snippet (not included)
<?php
/*
* MODX Revo indexer plugin. Allows fast TV filter searches using custom snippet (not included)
*
* License: public domain
*
* Created by: Jeroen Kenters / www.kenters.com
* First released: 2012-02-21 (yyyy-mm-dd)
*
* !!!!!!!Important!!!!!!!
$(function(){
$('#jqt').ajaxComplete(function(){
add_ga(); // add google analytics on each page load
});
$(document).ready(function() {
add_ga(); // add google analytics to the first page
});
function add_ga() {
<?php
/* LangRouter
* ==========
*
* This plugin is meant to be used with Babel extra for MODX Revolution. It
* takes care of switching contexts, which hold translations, depending on URL
* requested by client. LangRouter works with so called subfolder based setup,
* in which many languages are served under a single domain but are
* differentiated by a virtual subfolder indicating the language, eg.
* mydomain.com/pl/.
<?php
/**
* Example of how to fetch your own db table records cached, without using the snippet cached.
*
* Useful when the user can filter the data, like in a seach engine
*
* @package yourpackage
*/
$yourpackage = $modx->getService('yourpackage','yourpackage',$modx->getOption('yourpackage.core_path',null,$modx->getOption('core_path').'components/yourpackage/').'model/yourpackage/',$scriptProperties);
@enminc
enminc / modx.batchRemoveContexts
Created October 2, 2013 06:05
Simple utility script to remove all undesired context and associated resources from modx db
$dontRem = array('web','mgr'); /* add any additional context you dont wish to have removed here */
$contexts = $modx->getCollection('modContext');
foreach($contexts as $ctx){
$key = $ctx->get('key');
if(!in_array($key,$dontRem)) {
$response = $modx->runProcessor('context/remove',array('key'=>$key));
if ($response->isError()) {
echo $response->getMessage() . '<hr/>';
@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/>';
<?php
/**
* =========================
* defaultTemplateByParentTv
* =========================
*
* Plugin for modX Revolution
* Set default template for children of a ressource
*
* Author: