Created
April 28, 2020 16:55
-
-
Save MikeCraig418/ae638351048b47f74f345c91ff161dd7 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 | |
| require_once(ROOT . '/tbs/tbs_class.php'); | |
| require_once(ROOT . '/tbs/tbs_plugin_opentbs.php'); | |
| class Documentmerger | |
| { | |
| function mergeDocument($template = '', $data = [], $file = '') | |
| { | |
| $TBS = new clsTinyButStrong; | |
| $TBS->Plugin(TBS_INSTALL, OPENTBS_PLUGIN); | |
| $TBS->LoadTemplate($template, OPENTBS_ALREADY_UTF8); | |
| foreach ($data as $fieldKey => $fieldValues) { | |
| $TBS->MergeField($fieldKey, $fieldValues); | |
| } | |
| $TBS->Show(OPENTBS_FILE, $file); | |
| } | |
| } | |
| $docMergeObj = new Documentmerger(); | |
| $mergeFields = []; | |
| $mergeFields['common'] = []; | |
| $mergeFields['common']['date'] = date('Y - m - d'); | |
| $docMergeObj->mergeDocument('path to template file', $mergeFields,'path to target new file'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment