MODX Community

Get value within TV's html attribute


I’m new to Modx so I don’t know if this is possible or not.

My TV, in this case [[*myTV]] outputs the following:

<data value=''>Description</data>

Is there a way to only display the data value in the front-end? In this case I just want to display the url.


So I’m a bit confused. The expression [[!myTV]] would mean, that you call a snippet with the name myTV to output some data. In this case you could change the snippet to alter the output.

If you meant to write [[*myTV]] and the content of your tv is actually <data value=''>Description</data>, then you can change it with a custom snippet or a custom output modifier.

Yes, I actually meant [[*myTV]], I have edited my question. Thanks for spotting that.

What kind of TV is it that it outputs <data value="...">...</data>? Don’t think I’ve seen a structure like that before.

Do you have a non-default output type set on the TV?

It’s a multi-select TV with default output but the items are inside HTML data tags.

Ah, okay. So that’s just the way you’ve set up the values in the TV (or someone that built it before you).

You’re going to need to create a custom snippet to parse that to output only the value I reckon. Perhaps it’s parseable with PHPs DOMDocument? If not, some regex or string manipulation would do the trick so long as your values are consistently formed.

If you’re not too late in the development of the site, I’d also suggest rethinking what you store in the TV values. Perhaps there are better ways to accomplish what you need, but sometimes you gotta work with what you have.

1 Like

From one of your comments on Stack Overflow it sounds as if the TV only contains the URL. I’m guessing the rest of the data tag is in the template…? But in order to help I think we’d need to see the template code where you’re calling this tv, as well as any other details about this tv.

1 Like

This has been fixed by calling a snippet from the TV tag. Like this [[*vimeoSelector:vimeoURL]]

The snippet filters all the TV items using simpleXML.