I am trying to create a Template Variable (of type Checkbox) which, when selected, will insert a chunk of HTML (containing mostly some JavaScript code) into the page where it is called.
I have tried using "@CHUNK chunkname" as the value, and also pasting the full code into the Template Variable creation form, but neither seems to work.
Both the data-in-field and @CHUNK method seem to end up with the TV data being embedded in the page editor form (view source) when I edit a page which uses this TV.
I suspect that the problem is caused by the JavaScript code containing the MODx TV value separator ("
||"), as follows:
as when I look in the page editor form source it closes the 'value' string after the _paq text and then proceeds with
id="tv_0" name="tv15[]" onchange="documentDirty=true;" /><label for="tv_0">
at which point my text gets inserted (starting from the beginning again) with the label above closing after _paq (again, getting caught by the TV value separator) and then the rest of my text getting mashed into a checkbox input value with the HTML special characters escaped.
This then gets tangled up with the "Settings" tab in the MODx editor and it all goes wrong from there..
Is there any way that I can safely insert this code into a TV?
I have attached the intended code and the faulty page source as it is probably a bit hard to explain otherwise!
[ed. note: david55 last edited this post 10 years, 10 months ago.]