Created
June 12, 2016 18:21
-
-
Save Realetive/b41f668643e0afc32b7efee1a338204f to your computer and use it in GitHub Desktop.
Auto set up Media Source for MS2Gallery by template
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if ( $modx->event->name == 'OnDocFormSave' && $mode == modSystemEvent::MODE_NEW ) { | |
switch ( $resource->get( 'template' ) ) { | |
case 1: | |
$properties = $modx->fromJSON( $resource->get( 'properties' ) ); | |
$properties[ 'ms2gallery' ] = array( 'media_source' => 2 ); | |
break; | |
default: | |
break; | |
} | |
$resource->set( 'properties', $modx->toJSON( $properties ) ); | |
$resource->save(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment