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;
@splittingred
splittingred / prehook.profile.php
Created August 26, 2011 17:48
PreHook for FormIt to load User data into form
<?php
if (!$modx->user->hasSessionContext($modx->context->get('key')) return '';
$userArray = $modx->user->toArray();
$profile = $modx->user->getOne('Profile');
if ($profile) {
$userArray = array_merge($profile->toArray(),$userArray);
$extended = $profile->get('extended');
if (!empty($extended) && is_array($extended)) {
<?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 / activeuser.chunk.tpl
Created September 22, 2011 13:26
A MODX Snippet to show active, logged in users
<li>[[+username]]</li>
@splittingred
splittingred / install.sh
Created September 22, 2011 21:35
Bash script to install a new MODX Revolution 2.2+ install via CLI
Examples of above script:
# into a standard directory, where config.xml resides in the current working directory
sh install.sh /home/modx/public_html/
# with a custom config.xml file
sh install.sh /home/modx/public_html/ /opt/local/modx/config.xml
@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 / 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 / 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 / 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