MODX3 Custom code, how to use modx tag parser?

Hello,

is it possible to custom use internal parser für MODX tags?

I have a resource with text and some modx tags inside.
I use this instead of chunks, so the customer could change texts for emails.

I a processor I read this content and now I am asking me how is it possible to use MODX tag parser insteed of simple str_replace.

Thank you in advance for tipps.

bye
Chris

What kind of tags do you have in this text? Are these resource fields and TVs?
If that’s not the case and you have an array with all the values, then create a temporary chunk (with $modx->newObject()), add the content with setContent() and use the process() function to parse it.

own tags like

[[+order_nr]]

and I have an array with values such as:

ordernr => 23424

Creating a temporary chunk object should work in this case:

<?php
use MODX\Revolution\modChunk;

$properties = ['order_nr' => 23424];
$content = "[[+order_nr]]";

$chunk = $modx->newObject(modChunk::class);
$chunk->setContent($content);
$chunk->setCacheable(false);
$parsed_text = $chunk->process($properties);

thank you very very much.
That’s it. It runs.

Perfect.

:pray: