Last active
July 16, 2021 12:53
-
-
Save mnoskov/2cd2f53e23c4e0d22ffd557fb17ab729 to your computer and use it in GitHub Desktop.
PageBuilder Content Replace
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') { | |
$document = $modx->getDocument($id); | |
if ($document['template'] == 6) { | |
$content = $modx->runSnippet('PageBuilder', [ | |
'docid' => $id, | |
'container' => 'page', | |
'placement' => 'tv', | |
'tv' => '11', | |
]); | |
$modx->db->update([ | |
'content' => $modx->db->escape($content), | |
], $modx->getFullTablename('site_content'), "`id` = '$id'"); | |
} | |
} |
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 | |
// указать название сниппет в параметрах плагина evoSearch | |
foreach (['container1' => 1, 'container2' => 2] as $container => $tv) { | |
$data['content'] .= strip_tags($modx->runSnippet('PageBuilder', [ | |
'docid' => $data['id'], | |
'container' => $container, | |
'placement' => 'tv', | |
'tv' => $tv, | |
])); | |
} | |
return $data; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment