We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36425
    • 49 Posts
    hi!

    i have a code in my extra

    OStore.tree.cat = function(config){
        config = config || {};
        Ext.applyIf(config,{
            url: OStore.config.connectorUrl
            ,action: 'mgr/cat/getnodes'
            ,expandFirst: true
            ,rootId: '0'
            ,rootName: 'Top categories'
            ,rootVisible: true
            //,sortAction: 'categories/nodesUpdate'
        });
        OStore.tree.cat.superclass.constructor.call(this,config);
    };
    Ext.extend(OStore.tree.cat,MODx.tree.Tree,{
    
    });
    Ext.reg('ostore-panel-cats',OStore.tree.cat);


    okey i cant understand, what i must to return in my processor getnodes.class.php ?
    and anouther question is, how i can see in js ( via alert for example ), what return my processor (,action: 'mgr/cat/getnodes' )

    i trying return json array, but not help... maybe modx have standart class that return treenodes from table, like this?
    class OStoreGetListProcessor extends modObjectGetListProcessor {
        public $classKey = 'osWh';
        public $languageTopics = array('ostore:default');
        public $defaultSortField = 'name';
        public $defaultSortDirection = 'ASC';
        public $objectType = 'ostore.wh';
    }
    return 'OStoreGetListProcessor';
      • 37743
      • 49 Posts
      The easiest way to see raw responses from connectors/processors is to use Firbug/Firefox as it will let you see precisely what was returned including response headers.

      In terms of formatting the response, take a look at the response from the modResourceGetNodesProcessor class (the processor that returns the Resource file tree). Basically its an array of objects describing the nodes. An example:

      [{
      	"text":"Node 1 title <span dir=\"ltr\">(1)<\/span>"
      	,"id":"web_1"
      	,"pk":1
      	,"cls":"icon-document x-tree-node-leaf icon-resource psave pview pedit pduplicate pnew pnew_modDocument pnew pnew_modSymLink pnew pnew_modWebLink pnew pnew_modStaticResource pqcreate pqupdate pdelete pundelete ppublish punpublish"
      	,"type":"modResource"
      	,"classKey":"modDocument"
      	,"ctx":"web"
      	,"hide_children_in_tree":0
      	,"qtip":""
      	,"preview_url":"http:\/\/localhost\/modx\/"
      	,"page":"?a=30&id=1"
      	,"allowDrop":true
      	,"hasChildren":false,"children":[],"expanded":true
      },{
      	"text":"Node 2 title <span dir=\"ltr\">(2)<\/span>"
      	,"id":"web_4"
      	,"pk":4
      	,"cls":"icon-translateddocument x-tree-node-leaf icon-resource psave pview pedit pduplicate pnew pnew_modDocument pnew pnew_modSymLink pnew pnew_modWebLink pnew pnew_modStaticResource pqcreate pqupdate pdelete pundelete ppublish punpublish"
      	,"type":"modResource"
      	,"classKey":"modTranslatedDocument"
      	,"ctx":"web"
      	,"hide_children_in_tree":0
      	,"qtip":"<i>  <\/i>"
      	,"preview_url":"http:\/\/localhost\/modx\/translated-page.html"
      	,"page":"?a=30&id=2"
      	,"allowDrop":true
      	,"hasChildren":false
      	,"children":[]
      	,"expanded":true
      },{	
      	"text":"Node 3 title <span dir=\"ltr\">(3)<\/span>"
      	,"id":"web_5"
      	,"pk":5
      	,"cls":"icon-translateddocument x-tree-node-leaf icon-resource psave pview pedit pduplicate pnew pnew_modDocument pnew pnew_modSymLink pnew pnew_modWebLink pnew pnew_modStaticResource pqcreate pqupdate pdelete pundelete ppublish punpublish"
      	,"type":"modResource"
      	,"classKey":"modTranslatedDocument"
      	,"ctx":"web"
      	,"hide_children_in_tree":0
      	,"qtip":""
      	,"preview_url":"http:\/\/localhost\/modx\/getresources-test.html"
      	,"page":"?a=30&id=3"
      	,"allowDrop":true
      	,"hasChildren":false
      	,"children":[]
      	,"expanded":true
      }]
        • 36425
        • 49 Posts
        hmm... i can't use it for custom tables? I understood correctly? or maybe some examples, please... [ed. note: gaserge last edited this post 14 years, 4 months ago.]
          • 37743
          • 49 Posts
          You can use it for all the custom tables you want. To tie it in to a custom table you will need to http://rtfm.modx.com/display/revolution20/Using+Custom+Database+Tables+in+your+3rd+Party+Components"" target="_blank" rel="nofollow">create a schema for that table. One shortcut would be using http://rtfm.modx.com/display/ADDON/CMPGenerator"" target="_blank" rel="nofollow">CMPgenerator

          If you don't want to go that far, just return an array of your custom objects e.g.
          [{
              "title": 'Category 1'
             ,"dateAdded": '2012-10-1'
             ,"anotherCustomProperty": 'custom property value'
          },{
              "title": 'Category 2'
             ,"dateAdded": '2012-09-02'
             ,"anotherCustomProperty": 'custom property value'
          }]
            • 36425
            • 49 Posts
            i realy want to use modx api, but sometimes it harder than write it myself
            i have table... but cant do correct class.

            my big problem is using modx api, i'm too newby with it...
            class OStoreGetNodesProcessor extends modResourceGetNodesProcessor {
            public $itemClass = 'osCat';

            }
            return 'OStoreGetNodesProcessor';
            osCat is already created and works ( if get it by modObjectGetListProcessor for example.)

            but, on GetNodesProcessor
            firebug returns 500 ise, for this query

            what i need to put in a class, for work it correctly? [ed. note: gaserge last edited this post 14 years, 4 months ago.]
              • 36425
              • 49 Posts
              hmmm.... how i can add to tbar of modx tree my button?
              or where i can see js functions of standart buttons, like refresh, expand all, collapse all.
                • 36425
                • 49 Posts
                solved by using in js "useDefaultToolbar", but handler doesnt work...

                ,useDefaultToolbar: true
                ,tbar: [
                    {
                    icon: MODx.config.template_url+'images/restyle/icons/folder.png'
                    ,cls: 'x-btn-icon'
                    ,tooltip: { text: _('ostore.cat.create') }
                    ,handler: this.test
                    }
                ]
                ,test: function(){
                    alert('test')
                }


                ok i'm trying do like
                ,handler: function() { alert('ok') }

                its work.. then i try alert(this.test) - it's return undefined
                its realy unclear, handler: this.refresh, for example - works
                what could be the problem? [ed. note: gaserge last edited this post 14 years, 4 months ago.]
                  • 36425
                  • 49 Posts
                  wow, i solved it. but realu dont understund why it must have such syntax:

                  ok we have

                  OStore.tree.cat = function(config){
                  ...
                  ,useDefaultToolbar: true
                  ,tbar: [
                      {
                      icon: MODx.config.template_url+'images/restyle/icons/folder.png'
                      ,cls: 'x-btn-icon'
                      ,tooltip: { text: _('ostore.cat.create') }
                      ,handler: this.test
                      }
                  ]
                  ...
                  });

                  then extend Ext.extend(OStore.tree.cat,MODx.tree.Tree); like this:

                  Ext.extend(OStore.tree.cat,MODx.tree.Tree,{
                  test: function(){
                      alert('test')
                  }
                  });

                  and function has earned... why?



                  p.s.: nobody knows how to use "modResourceGetNodesProcessor" for cusom tables? [ed. note: gaserge last edited this post 14 years, 4 months ago.]
                    • 18373 ☆ A M B ☆
                    • 3,141 Posts
                    modResourceGetNodesProcessor is really specific for modResource's, you will need to write your own for your own table.

                    It returning a 500 ISE sounds like you didn't require_once the modResourceGetNodesProcessor class file in your processor, which is in core/model/modx/processors/resource/getnodes.class.php. You can use that as a base for your own, tho it's quite large and I doubt you will need it all in your own table.
                      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.
                      • 36510
                      • 10 Posts
                      Had the same problem.

                      For what I know, you have to extend modObjectProcessor and not modObjectGetListProcessor else you get the results in a separate note.

                      Then just implement process method and it should be fine.

                      	/*
                      	* Get list by parent
                      	*/    
                      	public function process() {
                      
                      		// Get parent ID
                      		$parentId = str_replace('n_ug_','', $this->getProperty('id') );
                      
                      		// Get child tags
                      		$tagList = $this->getTags($parentId);
                      
                      		// Write list
                      		$newList = array();
                      			foreach( $tagList as $item ){
                      
                      			// Check if children exist
                      			$itemChilds =  $this->getTags($item->get('id'));
                      			if( !empty($itemChilds) ){
                      				$leaf = false;
                      				$type = 'dir';
                      			}else{
                      				$leaf = true;
                      				$type = 'file';        	
                      			}
                      
                      			// Write new node item
                      			$newList[] = array(
                      				'text' => $item->get('name'),       
                      				'name' => $item->get('name'),       		    	
                      				'description' => $item->get('description'),       
                      				'parentid' => $item->get('id'),
                      				'id' => 'n_ug_0' . $item->get('id'),
                      				'leaf' => $leaf,
                      				'type' => $type,
                      				'cls' => ''
                      			);
                      		}    
                      		return $this->toJSON($newList);
                      	}
                      


                      Fore some more details http://blog.sofasurfer.org/2012/09/17/modx-tree-tree-on-custom-manager-page/?preview=true&preview_id=1171&preview_nonce=ddb180d86a:
                        Home is where the hard disk is:
                        http://sofasurfer.org