We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 16863
    • 29 Posts
    I have built a few relatively simple Custom Manager Pages to expose custom tables on the database. I don’t entirely know what I’m doing, but I’ve worked my way through using various examples and tutorials that are available.

    One thing I haven’t been able to find is a list of available xtypes that I can use to create and update items on my grid. All of the examples use ’textfield’ and ’textarea’ which are fine for most everything I’m doing, but I’d like to be able to provide the ability to browse the server for files and edit rich text.

    So I’m looking for a list of (hopefully with code examples) xtypes that are available out-of-the-box and a nice thorough tutorial about how to create and implement custom xtypes.

    Any help would be appreciated.
      • 4172
      • 5,888 Posts
      made xdbedit for that, where you can use tv-input-types for table-fields.
      http://modxcms.com/forums/index.php/topic,56636.0.html
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 18373 ☆ A M B ☆
        • 3,141 Posts
        Here’s a bunch for ExtJS... http://arangluv.tistory.com/18


        And here’s something that may get you started with your own xtypes:
        Ext.onReady(function() { // Load the xtype (= "template") when ready
            MODx.load({ xtype: 'versionx-page-home'}); // xtype should match the first parameter of Ext.reg
        });
        
        VersionX.page.Home = function(config) { // Config for page.Home
            config = config || {};
            Ext.applyIf(config,{ 
                components: [{ 
                    xtype: 'versionx-panel-hometabs',
                    renderTo: 'versionx-panel-home-div' // Div that should be in your page
                }]
            }); 
            VersionX.page.Home.superclass.constructor.call(this,config);
        };
        Ext.extend(VersionX.page.Home,MODx.Component); // Extend it from the MODx.Component class.
        Ext.reg('versionx-page-home',VersionX.page.Home); // First parameter is the xtype to be referenced, second the config


        VersionX.panel.Hometabs = function(config) {
            config = config || {};
            Ext.apply(config,{
                border: false
                ,baseCls: 'modx-formpanel' // Basic class to use -> styles the whole thing.
                ,items: [{ // Multidimensional array of items in the panel.Hometabs config
                    html: '<h2>'+_('versionx.versionx')+'</h2>'
                    ,border: false
                    ,cls: 'modx-page-header' // Header class
                },{
                    xtype: 'modx-tabs' // Use the MODx class template
                    ,bodyStyle: 'padding: 10px'
                    ,defaults: { border: false ,autoHeight: true }
                    ,border: true
                    ,stateful: true
                    ,stateId: 'versionx-home-tabpanel'
                    ,items: [{
                        title: _('versionx.overviewTitle')
                        ,defaults: { autoHeight: true }
                        ,items: [{
                            html: '<p>'+_('versionx.overviewDescription')+'</p>'
                            ,border: false
                            ,bodyStyle: 'padding: 10px'
                        },{ 
        						html: '<h3>'+_('versionx.devTitle')+'</h3>'+
        							'<p>'+_('versionx.devDescription')+'</p>'
        						,border: false
        						,bodyStyle: 'padding: 10px'
        					 }]	
                    },{
                        title: _('versionx.resourcesTitle')
                        ,defaults: { autoHeight: true }
                        ,items: [{
                            html: '<p>'+_('versionx.resourcesDescription')+'</p>'
                            ,border: false
                            ,bodyStyle: 'padding: 10px'
                        },{
                            xtype: 'versionx-grid-resources'
                            ,preventRender: true
                        }]
                    },{
        					title: _('versionx.chunksTitle')+' and '+_('versionx.snippetsTitle')+' coming in 1.1'
        					,disabled: true
        				}
        				
        				/*{
                        title: _('versionx.chunksTitle')
                        ,defaults: { autoHeight: true }
        					 ,disabled: true
                        ,items: [{
                            html: '<p>'+_('versionx.chunksDescription')+'</p>'
                            ,border: false
                            ,bodyStyle: 'padding: 10px'
                        }]
                    },{
                        title: _('versionx.snippetsTitle')
                        ,defaults: { autoHeight: true }
        					 ,disabled: true
                        ,items: [{
                            html: '<p>'+_('versionx.snippetsDescription')+'</p>'
                            ,border: false
                            ,bodyStyle: 'padding: 10px'
                        }]
        				}*/]
                }]
            });
            VersionX.panel.Hometabs.superclass.constructor.call(this,config);
        };
        Ext.extend(VersionX.panel.Hometabs,MODx.Panel); // Extend it from the base MODx Panel
        Ext.reg('versionx-panel-hometabs',VersionX.panel.Hometabs); // Register xtype (template)




        I have hopes to be able of writing some documentation on "getting started" with modExt / ExtJS, but that wont be ready for a while.
          Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

          Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
          • 22757
          • 41 Posts
          I’m having the same problem. But it doesn’t seem to be well documented yet. Some of them are mentioned in the modx documentation though. For basic types you can use the ExtJs ApiDoc. And for the rest i had to go through the modext.js code...

          a file browser is modx-combo-browser btw wink
            • 28215
            • 4,149 Posts
            All of the ones included on page load can be found in:

            manager/assets/modext/widgets/core/modx.combo.js
              shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
              • 22757
              • 41 Posts
              nice smiley can you give me an example of a combo loading its content via ajax request? I think this is defined in lines 5 to 43. But how do i have to pass the parameters to get it working. I’m kind of unable right now to figure out. Thanks smiley

              P.S: I also need to pass values from other fields as parameters and to reload the store if they are changed. Any ideas?
                • 27519
                • 275 Posts
                Here’s an example of a combo in ExtJs (it shows a list of countries and passes the selected country id back when the form is submitted). It also uses a custom template to display each entry in the list:

                Tariffs.combo.Countries = function(config){
                	config = config || {};
                	Ext.applyIf(config,{
                		hiddenName: 'country'
                		,name: 'country'
                        ,width: 250
                        ,listWidth: 300
                		,displayField: 'name'
                		,valueField: 'id'
                		,fields: ['id','name','code']
                        ,tpl: new Ext.XTemplate('<tpl for="."><div class="x-combo-list-item"><span style="font-weight: bold">{name}</span>'
                            ,' ({code})</div></tpl>')
                		,url: Tariffs.config.connector_url
                		,emptyText: 'Select a country...'
                		,baseParams:{
                			action: 'mgr/booking/getcountrylist'
                		}
                	});
                	Tariffs.combo.Countries.superclass.constructor.call(this,config);
                };
                


                ... and the accompanying PHP that scoops the data from the database and transforms to JSON format.

                <?php
                /**
                 * Get a list of Countries
                 *
                 * @package tariffs
                 * @subpackage processors
                 */
                
                $countries = $modx->getCollection('Country');
                /* iterate */
                $list = array('results' => array());
                foreach ($countries as $country) {
                    $countryArray = $country->toArray();
                    $list['results'][]= $countryArray;
                }
                return $this->toJSON($list);
                


                I’m not too sure if the JSON conversion is actually necessary. It’s been a while since working with ExtJs.

                Loading is performed asynchronously (AJAX), which I think is default for ExtJs.

                You could also implement this with a custom JSON store and a MODx Ajax call. That is however more complicated and requires more code.

                As for your reload question: if you mean reloading the list in the combo box, I suppose you could put listeners on them that fire when the values of the fields change and force a reload of the list. Haven’t got any examples of that however. ExtJs combos can also be configured with a refresh button but that would make the refresh a user controlled action. Not sure if you want that...

                Hope this helps.
                  MODx Revolution / MAMP / OS X
                  • 22757
                  • 41 Posts
                  Thank you very much! Especially the simple AJAX loading and the custom template are of my interest.

                  I think JSON encoding is required.
                    • 32674
                    • 101 Posts
                    Little late to the party... ...but if you haven’t found it already, here’s a v3.3 list of xtypes with some initialization code if you click the through the types:

                    http://dev.sencha.com/deploy/dev/docs/?class=Ext.Component