| Only use this documentation for pre-2.2 or core submissions. Refer to the Adding a Custom TV Type doc for the proper way to build custom TVs in 2.2 which allows easy packaging. |
What are Custom TV Input Types?
MODx Revolution allows you to create your own custom TV input types (similar to the textbox, radio, textarea, richtext, etc types already available) for your Template Variables.
Creating the Files
To create a custom TV input type (let's say, one called "test"), you need a few things. Let's say my "test" TV input type loads a Template selecting combobox.
I'd first need 2 files:
- An input controller - put here: core/model/modx/processors/element/tv/renders/mgr/input/test.php
- An input template - put here: manager/templates/default/element/tv/renders/input/test.tpl
The input controller, test.php, would have:
$this->xpdo->lexicon->load('tv_widget'); // any other PHP i want here return $this->xpdo->smarty->fetch('element/tv/renders/input/test.tpl');
And the input template, test.tpl, for the default mgr theme would have (note that it is using Smarty syntax):
<select id="tv{$tv->id}" name="tv{$tv->id}" class="combobox"></select> <script type="text/javascript"> // <![CDATA[ {literal} MODx.load({ {/literal} xtype: 'modx-combo-template' ,transform: 'tv{$tv->id}' ,id: 'tv{$tv->id}' ,width: 300 {literal} ,listeners: { 'select': { fn:MODx.fireResourceFormChange, scope:this}} }); {/literal} // ]]> </script>
And there you go! A custom TV input type.

| You don't have to use the ExtJS code as shown here to have a custom input type. It could even just be a straight HTML input. It's really up to you. |