Thank you. But isn't OnParseDocument called multiple times?
And how to set the TV value (just for this request)?
$modx->resource->setTVValue()?
And how to strip all possible tags out from the content of the TV? Or just disallowing it's parsing? Is it just by replacing
[[ and ]] by & #091;& #091; and & #093;& #093;
?
UPD: it seems like the default Template Variables - such as pagetitle or content - are not requestable via $modx->resource->getTVValue("content"), one should use $modx->resource->get("content"). Same for setTVValue - replacing by set.
Basically these are not TVs but Resource Fields, but their tag syntax is the same as for TVs. Full list is here:
http://rtfm.modx.com/display/revolution20/Resources#Resources-ResourceFields
UPD2: OnLoadWebDocument seems to be the best case. Cause we have the content and TVs/Resource Fields available. Basically this is the event which occures before any tag rendering is performed.
UPD3: based on this script -
http://www.shawnwilkerson.com/modx-revolution/modx-snippets/showsnippet-snippet.html - I suppose, that indeed to disallow the tags parsing we need just do a
str_replace(array("[[", "]]"), array("& #091;& #091;", "& #093;& #093;"), $content);
UPD4: WARNING! setTVValue() actually saves the information into the database, and the content of the TV is not updated until next request! Is there a way to make the exact contrary - make the change only for current request and don't save in database?
UPD5: it seems that to make a TV parsable without using [ [*myTv:myFilter]] we need to make an TV Output Type - it's the only way. Basically, TV Output Types is exactly what is needed, it is even very logical to actually use them, but I thougth that it won't be needed and it is possible to perform by a plugin or such - an easier approach. Well, it is not.
There is a very good tutorial on about how to make it - described here:
http://rtfm.modx.com/display/revolution20/Adding+a+Custom+TV+Output+Type
Is there an addon/extension of a TV Output Type which enables the value of a TV to be processed by a snippet?
[ed. note: eiventeleiron last edited this post 15 years ago.]