D
D
denism3002022-03-17 17:20:06
MODX
denism300, 2022-03-17 17:20:06

How to pass an array from a snippet to a chunk in MODx?

For example, there is a snippet that should return an array, let's say this:

array(
    'value' => 'some_value', 
    'class   => 'some_class'
)

How can I use this array in a chunk to get the output
<span class="some_class">some_value</span>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Tarasov, 2022-03-17
@denism300

In the chunk (let it be called, say, `yourChunk`) specify:
<span class=""></span>
In the snippet, make the following call:

$output = $modx->getChunk('yourChunk',array(
   'class' => 'some_class',
   'value' => 'some_value'
));
return $output;

And you will get what you want.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question