Created
March 7, 2018 13:40
-
-
Save Semdevmaster/6b76431fc0fca15062d7bc39b2655ab0 to your computer and use it in GitHub Desktop.
Смена источника файлов для определённых шаблонов
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 == 'new') || ($modx->event->name == 'OnDocFormRender' && $mode == 'upd')) { | |
| switch ($resource->get('template')) { | |
| //ID шаблонов страниц | |
| case 1: | |
| case 2: | |
| case 3: | |
| //ID источника файлов | |
| $source = 1; | |
| break; | |
| case 4: | |
| case 5: | |
| $source = 2; | |
| break; | |
| } | |
| if ($source) { | |
| $properties = $resource->get('properties'); | |
| $properties['ms2gallery'] = array('media_source' => $source); | |
| $resource->set('properties', $properties); | |
| if ($modx->event->name == 'OnDocFormSave') { | |
| $resource->save(); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment