Skip to content

Instantly share code, notes, and snippets.

View FuzzicalLogic's full-sized avatar
🚖
Porting code from another repository...

Donald Atkinson FuzzicalLogic

🚖
Porting code from another repository...
View GitHub Profile
@FuzzicalLogic
FuzzicalLogic / OnBinaryResourceLoad
Created March 16, 2015 13:01
Sample MODX Revolution Plugin for Binary Resources
<?php
if ($modx->event->name == 'OnLoadWebDocument'
&& $modx->resource->get('type') == 'document') {
$mime = $modx->resource->get('contentType');
$isBinary = $modx->getObject('modContentType', array('mime_type' => $mime))->get('binary');
if ($isBinary == 1) {
$bytes = base64_decode($modx->resource->get('content'));
}
@FuzzicalLogic
FuzzicalLogic / setParentTemplate.snippet.php
Created September 13, 2012 06:18
MODx Revolution: Allows you to "nest" a MODx Revolution Template within another MODx Revolution Template. Requires the use of a Template Switcher plugin
<?php
// Requires an Template ID
if (empty($id))
return '';
else
{//Get the Template
$parent = $modx->getObject('modTemplate', $id);
// Must be a valid Template ID
if (empty($parent))
return '';