MODX Community

Replacement for @EVAL in TVs?

Now that @EVAL is going to be removed, what alternatives will we have for generating TV values? For example, I frequently use scripts to generate custom lists of ListBox items, like this:

@EVAL return $modx->runSnippet(‘listSpeakers’);

Is there currently some other way to do this? If not, what’s the plan for doing this without EVAL in upcoming versions of MODX?

1 Like

I think, you still can use @CHUNK and put a snippet into that chunk

1 Like

Great idea. Yes, that works fine. It would be nice at some point to have a @SNIPPET option.

2 Likes

You can also replace the TV tag with a snippet tag. This should do exactly what your code above does:

[[!listSpeakers]]

Tried it, but that doesn’t work in an Input Option Values field for a TV.

It should work if you put it directly in a resource or template, or in a text Tpl chunk.

I’m talking about populating the values in a multi-select box in the manager, like this:

Screen Shot 2020-01-17 at 5.52.19 PM

this is how I allways had done it in the past.
Did you try to call it with the cached version?
I think, it has to be called cached in that case.