We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 5340
    • 1,624 Posts
    HI,

    I needed a solution to display a custom tree in the manager

    Eg

    container 1[home]
    --container 11
    ----container 111
    ----container 112
    --container 12
    ----container 121
    ------container 1211
    ------container 1212
    ----container 122

    I needed to show only
    ----container 111
    and
    ------container 1212

    like

    container 111
    container 1212

    Note: to hide "container 112" and "container 1211" you need to use modx’s user grops/document groups

    Or how about displaying only the content of container 1212:
    -page 1
    -page 2
    -page 3


    It seems impossible to find a javascript solution, by changing the welcome.html from manager/media/style
    So I had to hack the nodes.php file.

    Solution:

    Step 1:

    create a file called tree-start-ids.cfg.php in manager/frames

    enter this code and modify it to your needs:
    <?
    //user group id => array of parent ids to start from
    $treeStartIds = 
    array(
    "5" => array (1270,1234),
    "2" => array (115)
    );
    ?>
    

    One can find the user Group Ids in the modx_membergroup_names table.

    Step 2:
    add the following code to the node.php from manager/frames
    insert the code before line "makeHTML($indent,$parent,$expandAll,$theme);"


    /*********************Hack to start the tree from the configured IDs - by Cipa******************************/
    	//include the cfg file
    	include_once("tree-start-ids.cfg.php");
    	
    	
    	//only if parent is 0 or empty. Otherwise normal behavior is required
    	if(!$parent){
    		
    		//init startId var
    		$startIds = array();
    		
    		//only if user belongs to a group
    		if($_SESSION['mgrDocgroups']){ //$docgrp = implode(",",$_SESSION['mgrDocgroups']);
    			
    			//create start ids array
    			foreach($_SESSION['mgrDocgroups'] as $group){
    				//there is a start id for this group
    				if ($treeStartIds[$group]){
    					foreach($treeStartIds[$group] as $gr){
    						if (!in_array($gr,$startIds)){
    							array_push($startIds, $gr);
    							
    						}
    					}
    				}
    			}
    			
    			$noStartIds = count($startIds);
    			
    			if($noStartIds == 1){
    				//set parent - the call to makeHtml is below
    				$parent = $startIds[0];
    			}else{
    				foreach($startIds as $idx => $sId){
    					//set parent
    					$parent = $sId;
    					//if last one don't makeHtml - will be called below
    					if( ($idx + 1) != $noStartIds){
    						makeHTML($indent,$parent,$expandAll,$theme);
    					}
    				}
    			}
    		}
    	}
    /***************************************************/
    



    Waiting for ideas on how to get this working as plugin/module. I’m not sure it is possible.
    Maybe the configuration file can be generated through the manager.

    Thank You

    Update: This solution might not work if the user belongs to multiple user groups.


      • 7231
      • 4,205 Posts
      This is cool. smiley Maybe Jira it to see if it gets added somehow smiley
        [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

        Something is happening here, but you don&#39;t know what it is.
        Do you, Mr. Jones? - [bob dylan]
        • 20413
        • 2,877 Posts
        Nice! smiley
        Hack this now --> http://modxcms.com/forums/index.php/topic,34658.msg210557.html#msg210557 grin

        That is probably very hard.
          @hawproductions | http://mrhaw.com/

          Infograph: MODX Advanced Install in 7 steps:
          http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

          Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
          http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
          • 5340
          • 1,624 Posts
          Quote from: dev_cw at Apr 08, 2009, 08:02 AM

          This is cool. smiley Maybe Jira it to see if it gets added somehow smiley

          First I have to figure out a way to change the configuration file through the manager.
          Maybe a new field where you create a new User group.
            • 7231
            • 4,205 Posts
            Quote from: xpix at Apr 09, 2009, 11:48 AM

            Maybe a new field where you create a new User group.
            How about the manager equivlent to the field for selecting the Manager Login Startup which is used to select a front-end page to be redirected to when login in to the manager. Could add a new file Manager Tree Startup to use as a value.

            maybe this could be set via a plugin set to onManagerLogin that would set the tree startup as a session of cookie variable.

              [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

              Something is happening here, but you don&#39;t know what it is.
              Do you, Mr. Jones? - [bob dylan]
              • 25663 MODX Staff
              • 12,272 Posts
              Any enhancements that make sense should definitely be logged to JIRA.
                Ryan Thrash, MODX Co-Founder
                Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
                • 5340
                • 1,624 Posts
                I do not have good working solution but I can post the idea and link to this post. Maybe somebody has an idea on how to integrate this in the manager.