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.