We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 17403 ☆ A M B ☆
    • 183 Posts
    Looking around MODext, there are so many combo-box aliases extended from MODx.combo.ComboBox. But I did not find anything related to resource. Am I missing something?

    Just to name some of combo box:

    • Context (list of context): MODx.combo.Context
    • User (list of user): MODx.combo.User
    • Boolean (true/false): MODx.combo.Boolean

      zaenal.lokamaya
      • 17403 ☆ A M B ☆
      • 183 Posts
      Trying to create MODx.combo.ComboBox. It works but always output all resources.

      I don't know how to add criteria to the getList query. Changing the parent:5, for example, not works. But add limit:10 works.

      Any insight?

          ,url: MODx.config.connectors_url+'resource/index.php'
          ,baseParams: {
              action: 'getList'
              ,parent: 5 // <- did not works?
              ,limit: 10 // <- works
          }
      


      However I can add criteria to MODx.combo.User. Adding usergroup:2 works as expected, only output user from that usergroup.

          ,url: MODx.config.connectors_url+'security/user.php'
          ,baseParams: {
              action: 'getList'
              ,usergroup: 2 // <- works as expected
              ,limit: 0
          }
      



      Complete MODx.combo.Resource
      MODx.combo.Resource = function(config) {
          config = config || {};
          Ext.applyIf(config,{
              name: 'resource'
              ,hiddenName: 'resource'
              ,valueField: 'id'
              ,displayField: 'pagetitle'
              ,fields: ['id','pagetitle']
              ,url: MODx.config.connectors_url+'resource/index.php'
              ,baseParams: {
                      action: 'getList'
                      ,parent:0
                      ,limit:0
              }
              ,tpl: new Ext.XTemplate('<tpl for=".">'
                  ,'<div class="x-combo-list-item">'
                  ,'<h4 class="modx-combo-title">{pagetitle} ({id})</h4>'
                  ,'</div></tpl>')
          });
          MODx.combo.Resource.superclass.constructor.call(this,config);
      };
      Ext.extend(MODx.combo.Resource,MODx.combo.ComboBox);
      Ext.reg('modx-combo-resource',MODx.combo.Resource);
      
        zaenal.lokamaya
        • 17403 ☆ A M B ☆
        • 183 Posts
        Uh, just looking into the json output of MODx.config.connectors_url+'resource/index.php'... it output everything, including content, tv, etc.

        So it will be better to re-route the connector to custom snippet.
          zaenal.lokamaya
          • 17403 ☆ A M B ☆
          • 183 Posts
          Got it.

          Simply using action: 'search', and it will be processed by core/model/modx/processor/resource/search.class.php

          valid query:
          baseParams: {
              action: 'search'
              ,id: Integer
              ,parent: Integer
              ,pagetitle: String
              ,introtext: String
              ,description: String
              ,alias: String
              ,menutitle: String
              ,content: String
              ,published: Boolean
              ,unpublished: Boolean
              ,deleted: Boolean
              ,undeleted: Boolean
          }


          Or we can modify search.class.php and save it as searchlist.class.php. Then we use it using action: 'searchlist'

            zaenal.lokamaya
            • 40762
            • 54 Posts
            Hey just to thank you for posting your resource on the subject. I find it very hard to find documentation concerning modext and extjs
              Marc-Andre Audet
              • 47571
              • 2 Posts
              This helped a ton. Thanks lokamaya.