\\
|
{warning:title=Only use this documentation for pre-2.2 or core submissions. }Refer to the [Adding a Custom TV Type|revolution20:Adding a Custom TV Type - MODX 2.2] doc for the proper way to build custom TVs in 2.2 which allows easy packaging. {warning}\\
|
h2. 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]. h2. 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:
|
... {code} $this->xpdo->lexicon->load('tv_widget'); // any other PHP i want here return $this->xpdo->smarty->fetch('element/tv/renders/input/test.tpl'); {code} And the input template, test.tpl, for the default mgr theme would have (note that it is using [Smarty|http://smarty.net/] syntax): {code} <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>
|
{code}
|
And there you go\! A custom TV input type.
|
!customtv1.png!
|
... {note}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.{note} h2. See Also {pagetree:root=Template Variables} {scrollbar}
|