Skip to content

Instantly share code, notes, and snippets.

View splittingred's full-sized avatar
💭
🚀

Shaun McCormick splittingred

💭
🚀
View GitHub Profile
@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);
@splittingred
splittingred / gist:1151579
Created August 17, 2011 14:00
Example resolver
<?php
if ($object->xpdo) {
$modx =& $object->xpdo;
switch ($options[xPDOTransport::PACKAGE_ACTION]) {
case xPDOTransport::ACTION_INSTALL:
break;
case xPDOTransport::ACTION_UPGRADE:
break;
case xPDOTransport::ACTION_UNINSTALL:
break;
<?php
/**
* @var modX $modx
* @var modTemplateVar $this
* @var array $params
*
* @package modx
* @subpackage processors.element.tv.renders.mgr.input
*/
$modx->lexicon->load('tv_widget');
@splittingred
splittingred / snippet.getpagetitle.php
Created September 26, 2011 18:57
Gets a pagetitle of a specified resource
<?php
$id = $modx->getOption('id',$scriptProperties,$modx->resource->get('id'));
$pageTitle = '';
$resource = $modx->getObject('modResource',$id);
if ($resource) {
$pageTitle = $resource->get('pagetitle');
}
return $pageTitle;
@splittingred
splittingred / getlist.php
Created September 28, 2011 22:07
Driver-specific processor in MODX 2.2. This is the databasetables/getlist processor.
<?php
/**
* Gets a list of database tables
*
* @package modx
* @subpackage processors.system.databasetable
*/
class modDatabaseTableGetListProcessor extends modDriverSpecificProcessor {
public function checkPermissions() {
return $this->modx->hasPermission('database');
@splittingred
splittingred / create.class.php (new)
Created September 28, 2011 20:59
Old vs New MODX Processors (as of 2.2)
<?php
class modActionCreateProcessor extends modProcessor {
/** @var modAction $action */
public $action;
public function checkPermissions() {
return $this->modx->hasPermission('actions');
}
public function getLanguageTopics() {
return array('action','menu','namespace');
@splittingred
splittingred / updatefromgrid.class.php
Created September 29, 2011 15:40
Example of a derivative processor extending functionality
<?php
require_once (dirname(__FILE__) . '/update.class.php');
/**
* Update a setting from a grid
*
* @param string $key The key of the setting
* @param string $oldkey The old key of the setting
* @param string $value The value of the setting
* @param string $area The area for the setting
@splittingred
splittingred / create.class.php
Created November 1, 2011 21:26
2.2 Chunk Create Processor
<?php
require_once (dirname(dirname(__FILE__)).'/create.class.php');
/**
* Creates a chunk.
*
* @param string $name The name of the chunk.
* @param string $description (optional) The description of the chunk.
* @param integer $category The category the chunk is assigned to.
* @param string $snippet The code of the chunk.
* @param boolean $locked Whether or not the chunk can only be accessed by
<?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.
@splittingred
splittingred / update.class.php
Created November 2, 2011 18:53
The nice and short Category update processor in MODX 2.2
<?php
class modElementCategoryUpdateProcessor extends modObjectUpdateProcessor {
public $classKey = 'modCategory';
public $languageTopics = array('category');
public $permission = 'save_category';
public $objectType = 'category';
}
return 'modElementCategoryUpdateProcessor';