We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3749
    • 24,544 Posts
    I don't know, but it's definitely worth putting in the feature request if it's not there already.
      Did I help you? Buy me a beer
      Get my Book: MODX:The Official Guide
      MODX info for everyone: http://bobsguides.com/modx.html
      My MODX Extras
      Bob's Guides is now hosted at A2 MODX Hosting
    • discuss.answer
      • 42562
      • 1,145 Posts
      For persisting tab panel across page load ...
      I found this https://www.sencha.com/forum/showthread.php?80740-Save-layout-AND-active-tab-of-collapsable-tab-panel
      Not tested yet.


      RE: lettis
      For rearranging tabs, use plugin

      1. Go to resource / element tree
      2. In element tab, scroll way down ...find plugins header
      3. click the little plus sign on the plugins header to create a new plugin
      4. observe three tabs on new plugin page
      5. on first tab Create/Edit Plugin, give desired name: rearrangeMYtabs
      6. in Plugin code (php): textarea, paste the code exactly as it is - in previous post
      7. on second tab System Events, CTRL+F on browser to find this event: OnBeforeManagerPageInit
      8. click the corresponding checkbox on OnBeforeManagerPageInit event

      Active/Enabled Plugins fire each time MODX Manager is requested.
      The plugin can be set to fire at precise times and only at those times.
      In this case, it will fire just before a manager page initializes - gives your plugin ample chance to actually do its JavaScript work - of rearranging
        TinymceWrapper: Complete back/frontend content solution.
        Harden your MODX site by passwording your three main folders: core, manager, connectors and renaming your assets (thank me later!)
        5 ways to sniff / hack your own sites; even with renamed/hidden folders, burst them all up, to see how secure you are not.
        • 42562
        • 1,145 Posts
        This plugin might crash though, for resources that DO NOT have a TV attached to them via their template
          TinymceWrapper: Complete back/frontend content solution.
          Harden your MODX site by passwording your three main folders: core, manager, connectors and renaming your assets (thank me later!)
          5 ways to sniff / hack your own sites; even with renamed/hidden folders, burst them all up, to see how secure you are not.
          • 3749
          • 24,544 Posts
          @donshakespears -- would it be possible to check at the top of the plugin to see if the action is editing a resource and return if not?

          I think you could also do a $modx->getCount() on templateVarTemplates.
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting
            • 44665
            • 60 Posts
            sebastian-marinescu Reply #15, 8 years, 2 months ago
            I just had this problem. On resource/create I just show 2 Tabs via the FC. So the script broke and I saw an empty resource-form.

            The fix for me in @bezumkin's code is to check if the tabs we want to push back to MODx.tabs are not null:

            
            <?php
            switch ($modx->event->name) {
                case 'OnBeforeManagerPageInit':
                    
                    $modx->controller->addHtml('
                    	<script>
                    		Ext.ComponentMgr.onAvailable("modx-resource-tabs", function() {
                    
                    			// Order of tabs
                    			var tabs = {
                                    "modx-resource-settings": null,
                                    "modx-panel-resource-tv": null,
                    				"modx-page-settings": null,
                                    "modx-resource-access-permissions": null,
                                };
                                
                    			var i, item, id;
                    			for (i in this.items) {
                    				if (this.items.hasOwnProperty(i)) {
                    					item = this.items[i];
                    					id = item["id"];
                    
                    					// TV tab has no id for some reason
                    					if (id == undefined && item["xtype"] == "modx-panel-resource-tv") {
                    						id = "modx-panel-resource-tv";
                    					}
                    					tabs[id] = item;
                    				}
                    			}
                    			this.items = [];
                    			for (i in tabs) {
                    				if (tabs.hasOwnProperty(i) && tabs[i] !== null) {
                    					this.items.push(tabs[i]);
                    				}
                    			}
                    		});
                    	</script>
                    ');
                    
                    break;
            }
            
            
              • 34178
              • 212 Posts
              Very good ideas to solve this problem!!

              In this context I only miss (when saving a resource) the cursor to stay in that field where it has been right before saving a resource and if possible right at that position in the field the cursor exactly has been (I am not sure but I think this works by default if you don´t use this Plugin).

              Do you think this is also possible using Javascript? [ed. note: lettis last edited this post 8 years, 2 months ago.]
                • 44665
                • 60 Posts
                sebastian-marinescu Reply #17, 5 years, 7 months ago
                For anybody else looking to also order tabs from extras, like lets say Sterc's SeoTab: I had to listen to a component being available much later and then change it so it removes and re-adds the tabs, then updates. This is my currently working code:

                <?php
                switch ($modx->event->name) {
                    case 'OnBeforeManagerPageInit':
                        
                        $modx->controller->addHtml('
                        	<script>
                        	
                        	    // This should be a component that registers late
                                Ext.ComponentMgr.onAvailable("emptifier", function(){
                        	    
                        			// Order of tabs
                        			var tabs = {
                                        "collections-category-resources": null,
                                        "modx-resource-settings": null,
                                        "modx-panel-resource-tv": null,
                                        "seo-tab": null,
                        				"modx-page-settings": null,
                                        "modx-resource-access-permissions": null,
                                        "versionx-resource-tab": null
                                    };
                        	        
                        	        // Get completely loaded tabs
                        	        var modxTabs = Ext.getCmp("modx-resource-tabs");
                        	        
                        	        if (!modxTabs) {
                        	            return;
                        	        }
                                    
                        			var i, item, id;
                        			for (i in modxTabs.items.items) {
                        				if (modxTabs.items.items.hasOwnProperty(i)) {
                        					item = modxTabs.items.items[i];
                        					id = item["id"];
                        
                        					// TV tab has no id for some reason
                        					if (id == undefined && item["xtype"] == "modx-panel-resource-tv") {
                        						id = "modx-panel-resource-tv";
                        					}
                        					tabs[id] = item;
                        				}
                        			}
                        			
                        			for (i in tabs) {
                        				if (tabs.hasOwnProperty(i) && tabs[i] !== null) {
                        					modxTabs.remove(tabs[i], false);
                        					modxTabs.add(tabs[i]);
                        				}
                        			}
                        			
                        			modxTabs.update();
                        	    });
                        	    
                        	</script>
                        ');
                        
                        break;
                }
                [ed. note: sebastian-marinescu last edited this post 5 years, 7 months ago.]