C
C
Cheizer2020-01-27 12:12:28
MODX
Cheizer, 2020-01-27 12:12:28

Which way is faster with FENOM? loops or snippets?

Friends, I started to study FENOM, templates in files, etc., I understand and really faster, I saw a comparison of the parser table, that with a large number of parser FENOM is still faster, albeit a little, but I can’t understand one thing, faster through the snippet, or directly faster through foreach?

How fast so



Or so
{'!getImageList' | snippet : [
'tpl' => 'tpl.addressl',
'tvname' => 'address',
'docid' => $id,
]}


Or so
{set $address = json_decode($id | resource : 'address', true)}
{if $address}
{foreach $address as $item}
{$item.title}
{/foreach}
{/if}

But through foreach, as I understand it, there is one minus, there is no work with the cache as in the snippet.

And there is another option
{set $items = $_modx->runSnippet('!pdoMenuFenom', [
    'parents' => 0,
    'displayStart' => true,
    'toArray' => true,
])}
{foreach $items as $item}
    {$item['level']}
{/foreach}


Which option do you think will be more competent and faster to execute?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Tarasov, 2020-01-27
@an-tar

Faster through fenom, option 1 is no longer needed.
By and large, there is no difference from the second and third, except that in the second it is clearly possible to influence the non-shielding. in the third variant it is necessary to add to this account.
The fourth offhand is a little slower than the third, because still the chunk is tightened.
Yes, you can test it yourself, measure the time, you only need a lot of data in migx.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question