Skip to content

Instantly share code, notes, and snippets.

<?php
/*
* OpenExpedio ("xPDO") is an ultra-light, PHP 5.2+ compatible ORB (Object-
* Relational Bridge) library based around PDO (http://php.net/pdo/).
*
*
* This plugin is part of xPDO.
*
* xPDO is free software; you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
@rthrash
rthrash / Excerpt.php
Created October 6, 2010 23:26
A MODx filter for creating smart excerpts of long text passages
/**
* Excerpt
*
* Creates intro excerpts from long passages of text like a Ninja.
*
* @category snippet
* @version 1.0
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License (GPL)
* @autohor Kevin Marvin, Ryan Thrash
* @internal @modx_category Content
@rtripault
rtripault / getMany
Created November 16, 2010 17:18
The following code allows the retrieval of child document for the page the user is on. (source: http://www.unchi.co.uk/2010/11/16/modx-revolution-getmany-children/)
$criteria = $modx->newQuery('modResource');
$criteria->where(array(
'parent' => $modx->resource->get('id'),
'published' => 1,
'deleted' => 0,
));
$criteria->sortby('pagetitle','ASC');
$children = $modx->resource->getMany('Children',$criteria);
foreach($children as $var => $value)
{
@splittingred
splittingred / gist:1129536
Created August 6, 2011 17:20
merging arrays to send to modx->getChunk
<?php
$properties = array_merge($customObj->toArray(),$profile->toArray(),$user->toArray());
$output = $modx->getChunk('MyChunk',$properties);
@larscwallin
larscwallin / result.html
Created August 25, 2011 08:24
XPDO2HTML XSLT Script
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<html>
<head/>
<body class="xPDOObject" data-package="modx">
<form class="modAccess" name="modAccess">
<input type="hidden" name="class" value="modAccess"/>
<input type="hidden" name="extends" value="xPDOSimpleObject"/>
<input type="hidden" name="id" value=""/>
<fieldset>
<legend>modAccess</legend>
<?php
require_once (dirname(dirname(__FILE__)).'/create.class.php');
/**
* Create a snippet.
*
* @param string $name The name of the element
* @param string $snippet The code of the snippet.
* @param string $description (optional) A brief description.
* @param integer $category (optional) The category to assign to. Defaults to no
* category.
<?php
// First we require the xml2json file of course.
require_once($modx->getOption('core_path').'components/simplx/common/xml2json.php');
// xml2json simply takes a String containing XML contents as input.
// Remember that the preprocessor always get a parameter called $dataSet
// containing the complete dataSet recieved from the dataSourceUrl or the
// dataSet Snippet parameter.
/*
jquery.aggregate.js by Greg Brown 2011. See
http://gregbrown.co.nz/code/jquery-aggregate/ for details.
License information: http://gregbrown.co.nz/code/license/
*/
/*
@splittingred
splittingred / simple-benchmark.php
Created March 9, 2012 05:37
simple-benchmark.php
<?php
set_time_limit(0);
class Timer {
public $timer = 0;
public function start() {
$mtime = microtime();
$mtime = explode(" ", $mtime);
$mtime = $mtime[1] + $mtime[0];
$this->timer = $mtime;
@chucktrukk
chucktrukk / modx.api.connector.php
Created April 19, 2012 19:38
Load and instantiate MODxAPi from a directory
<?php
if( !isset($modx) ) {
/*Test the realpath by just starting with /../ and keep adding till you get where you're going*/
$modx_base_path = realpath(dirname(__FILE__) . '/../../../../../');
define('MODX_BASE_PATH', $modx_base_path.'/' );
$old_dir = getcwd();
chdir(MODX_BASE_PATH);
require MODX_BASE_PATH . 'manager/includes/config.inc.php';