added loop email tokens for CustomObjectsBundle which helps to send e…#382
added loop email tokens for CustomObjectsBundle which helps to send e…#382Ravi-topchunks wants to merge 2 commits intoacquia:5.xfrom
Conversation
…mails with the list of custom items from an Object
|
this PR contains email tokens which provides loop tokens this helps to add top products into the email with LIMIT. Please have a look at emailtokens.md |
LoopEmailTokens.md
Outdated
| @@ -0,0 +1,86 @@ | |||
| ## Custom object loop tokens | |||
There was a problem hiding this comment.
Please move this md file into the PR description under # DOCS heading. If this gets merged we'd copy that docs part into https://github.com/acquia/mc-cs-plugin-custom-objects/wiki
There was a problem hiding this comment.
The file should be removed from the PR.
escopecz
left a comment
There was a problem hiding this comment.
I think I'm commenting on the same things as our CI will. I let it run first.
DTO/LoopToken.php
Outdated
| /** | ||
| * @var string | ||
| */ | ||
| private $token; | ||
|
|
||
| /** | ||
| * @var int | ||
| */ | ||
| private $limit = 1; | ||
|
|
||
| /** | ||
| * @var string | ||
| */ | ||
| private $where = ''; | ||
|
|
||
| /** | ||
| * @var string | ||
| */ | ||
| private $order = 'latest'; | ||
|
|
||
| /** | ||
| * @var string | ||
| */ | ||
| private $customObjectAlias = ''; | ||
|
|
||
| private $loopContentTokens = []; | ||
|
|
||
| private $loopContent = ''; | ||
|
|
||
| public function __construct(string $token) | ||
| { | ||
| $this->token = $token; | ||
| } |
There was a problem hiding this comment.
| /** | |
| * @var string | |
| */ | |
| private $token; | |
| /** | |
| * @var int | |
| */ | |
| private $limit = 1; | |
| /** | |
| * @var string | |
| */ | |
| private $where = ''; | |
| /** | |
| * @var string | |
| */ | |
| private $order = 'latest'; | |
| /** | |
| * @var string | |
| */ | |
| private $customObjectAlias = ''; | |
| private $loopContentTokens = []; | |
| private $loopContent = ''; | |
| public function __construct(string $token) | |
| { | |
| $this->token = $token; | |
| } | |
| private int $limit = 1; | |
| private string $where = ''; | |
| private string $order = 'latest'; | |
| private string $customObjectAlias = ''; | |
| /** | |
| * @var string[] | |
| */ | |
| private array $loopContentTokens = []; | |
| private string $loopContent = ''; | |
| public function __construct(private string $token) | |
| { | |
| } |
Not sure what types are stored in the loopContentTokens array.
DTO/LoopToken.php
Outdated
| * | ||
| * {custom-object=product:sku | where=segment-filter |order=latest|limit=1 | default=Nothing to see here | format=or-list} | ||
| */ | ||
| class LoopToken |
There was a problem hiding this comment.
| class LoopToken | |
| final class LoopToken |
DTO/LoopToken.php
Outdated
| return $this->loopContentTokens; | ||
| } | ||
|
|
||
| public function addLoopContentToken($loopContentToken, $contentTokenParams): void |
There was a problem hiding this comment.
now fixed the bugs and removed .md file
LoopEmailTokens.md
Outdated
| @@ -0,0 +1,86 @@ | |||
| ## Custom object loop tokens | |||
There was a problem hiding this comment.
The file should be removed from the PR.
…mails with the list of custom items from an Object
Description:
DOCS
Custom object loop tokens
Custom items can be rendered in emails (or other content) using loop tokens.
Basic syntax
{custom-object-loop ...}: Opens the loop and defines which custom items to load.{/custom-object-loop}: Closes the loop. Everything between the opening and closing tags is repeated for each matching custom item.Loop parameters (
custom-object-loop)product-views). Required.segment-filteris implemented so far (and it is the default if omitted).WHEREconditions.latestis supported (and is the default if omitted).1if not provided.1, multiple items are rendered.Loop-value parameters (
custom-object-loop-value)objectused in the surroundingcustom-object-loop. If it does not match, it is ignored.name,price,color).default=Unknown).Examples
List product names bought by the contact:
Rendered example:
Render a small HTML block per product:
{custom-object-loop object=product-views | where=segment-filter | order=latest | limit=2} <div class="product"> <strong>{custom-object-loop-value object=product-views | field=name | default=Unknown}</strong><br> Price: {custom-object-loop-value object=product-views | field=price | default=0}<br> Color: {custom-object-loop-value object=product-views | field=color | default=Unknown} </div> {/custom-object-loop}Rendered HTML (for 2 products):
Warnings and limitations
ORconditions in the source segments for custom object filters.Steps to test this PR: