From 9f8e768cc0715c33f9bfdbf4ccc194dd88657443 Mon Sep 17 00:00:00 2001 From: Ilyas Ronef Date: Fri, 30 Sep 2022 13:50:02 +0400 Subject: [PATCH 1/3] * `\ddGetDocuments\Outputter\Yandexmarket\Outputter::construct_prepareFields`: Missed `$this->templates` initialization has been added. --- src/Outputter/Yandexmarket/Outputter.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Outputter/Yandexmarket/Outputter.php b/src/Outputter/Yandexmarket/Outputter.php index 1a29e8c..125b8f8 100644 --- a/src/Outputter/Yandexmarket/Outputter.php +++ b/src/Outputter/Yandexmarket/Outputter.php @@ -305,7 +305,7 @@ function __construct($params = []){ /** * construct_prepareFields - * @version 1.0.1 (2021-07-09) + * @version 1.0.2 (2022-09-20) * * @return {void} */ @@ -313,6 +313,7 @@ private function construct_prepareFields(){ //Convert fields to objects $this->shopData = (object) $this->shopData; $this->offerFields = (object) $this->offerFields; + $this->templates = (object) $this->templates; foreach ( $this->offerFields as $offerFieldName => From 4860cf360e1af565619a74b2928d6a07f891e85a Mon Sep 17 00:00:00 2001 From: Ilyas Ronef Date: Fri, 30 Sep 2022 14:29:02 +0400 Subject: [PATCH 2/3] =?UTF-8?q?+=20Outputters=20=E2=86=92=20Json=20?= =?UTF-8?q?=E2=86=92=20Parameters=20=E2=86=92=20`outputterParams->template?= =?UTF-8?q?s->{$docFieldName}`=20=E2=86=92=20Placeholders:=20The=20new=20p?= =?UTF-8?q?laceholders=20contain=20any=20document=20field=20name=20or=20TV?= =?UTF-8?q?=20specified=20in=20`outputterParams->docFields`.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 3 ++- src/Outputter/Json/Outputter.php | 13 +++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 1fe8224..b512f22 100644 --- a/README.md +++ b/README.md @@ -297,7 +297,8 @@ Get resources from custom DB table. It is useful for manipulations with doc field values through running snippets. Available placeholders: - * `[+value+]` — document field value + * `[+value+]` — the field value + * `[+`any document field or tv name`+]` — Any document field name or TV specified in `outputterParams->docFields` * Valid values: * `stringChunkName` * `string` — use inline templates starting with `@CODE:` diff --git a/src/Outputter/Json/Outputter.php b/src/Outputter/Json/Outputter.php index 75e1b20..1667faf 100644 --- a/src/Outputter/Json/Outputter.php +++ b/src/Outputter/Json/Outputter.php @@ -7,7 +7,7 @@ class Outputter extends \ddGetDocuments\Outputter\Outputter { /** * parse - * @version 2.2 (2021-07-12) + * @version 2.3 (2022-09-30) * * @param $data {Output} * @@ -39,9 +39,14 @@ public function parse(Output $data){ ){ $result_item[$docField] = \ddTools::parseSource(\ddTools::parseText([ 'text' => $this->templates->{$docField}, - 'data' => [ - 'value' => $result_item[$docField] - ] + 'data' => \DDTools\ObjectTools::extend([ + 'objects' => [ + $itemData, + [ + 'value' => $result_item[$docField] + ] + ] + ]) ])); } } From 7568809319a5aba0b62b3f9c79390baaee25a056 Mon Sep 17 00:00:00 2001 From: Ilyas Ronef Date: Fri, 30 Sep 2022 16:50:02 +0400 Subject: [PATCH 3/3] Prerelease --- CHANGELOG.md | 5 +++++ CHANGELOG_ru.md | 7 ++++++- README.md | 2 +- composer.json | 2 +- ddGetDocuments_snippet.php | 2 +- src/Snippet.php | 2 +- 6 files changed, 15 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 20727ee..0ab4bf7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ # (MODX)EvolutionCMS.snippets.ddGetDocuments changelog +## Version 1.6 (2022-09-30) +* \+ Outputters → Json → Parameters → `outputterParams->templates->{$docFieldName}` → Placeholders: The new placeholders contain any document field name or TV specified in `outputterParams->docFields`. +* \* Outputters → Yandexmarket: Critical error related to missing initialization of an object field has been fixed. + + ## Version 1.5 (2022-06-03) * \+ Parameters → `providerParams->groupBy`: The new parameter. Allows to group items that have the same field values into summary item (like SQL `GROUP BY`). See README. * \* README → Examples: HJSON is used for all examples. diff --git a/CHANGELOG_ru.md b/CHANGELOG_ru.md index 708470a..08481a3 100644 --- a/CHANGELOG_ru.md +++ b/CHANGELOG_ru.md @@ -1,7 +1,12 @@ # (MODX)EvolutionCMS.snippets.ddGetDocuments changelog -## Version 1.5 (2022-06-03) +## Версия 1.6 (2022-09-30) +* \+ Outputters → Json → Параметры → `outputterParams->templates->{$docFieldName}` → Плейсхолдеры: Новые плейсхолдеры. Содержат значения полей документа (и TV), указанных в `outputterParams->docFields`. +* \* Outputters → Yandexmarket: Исправлена критическая ошибка, связанная с отсутствием инициализации поля объекта. + + +## Версия 1.5 (2022-06-03) * \+ Параметры → `providerParams->groupBy`: Новый параметр. Позволяет сгруппировать элементы, имеющие одинаковые значения полей, в один сводный элемент (как SQL `GROUP BY`). См. README. * \* README → Примеры: HJSON используется для всех примеров. diff --git a/README.md b/README.md index b512f22..f4776b7 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ A snippet for fetching and parsing resources from the document tree or custom DB #### 1. Elements → Snippets: Create a new snippet with the following data 1. Snippet name: `ddGetDocuments`. -2. Description: `1.5 A snippet for fetching and parsing resources from the document tree or custom DB table by a custom rule.`. +2. Description: `1.6 A snippet for fetching and parsing resources from the document tree or custom DB table by a custom rule.`. 3. Category: `Core`. 4. Parse DocBlock: `no`. 5. Snippet code (php): Insert content of the `ddGetDocuments_snippet.php` file from the archive. diff --git a/composer.json b/composer.json index b4d95b3..e000a47 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "dd/evolutioncms-snippets-ddgetdocuments", "type": "modxevo-snippet", - "version": "1.5.0", + "version": "1.6.0", "description": "A snippet for fetching and parsing resources from the document tree or custom DB table by a custom rule.", "keywords": [ "modx", diff --git a/ddGetDocuments_snippet.php b/ddGetDocuments_snippet.php index 806834f..87efa10 100644 --- a/ddGetDocuments_snippet.php +++ b/ddGetDocuments_snippet.php @@ -1,7 +1,7 @@ 'outputFormat',