Am using jsTree + PHP, and I would like to load up two different trees from two different database tables, depending on what user type the logged in user is.
I tracked down the code to the “class.tree.php” file,
class json_tree extends _tree_struct {
function __construct($table = 'tree', $fields = array(), $add_fields = array("title" => "title", "type" => "type")) {
parent::__construct($table, $fields);
$this->fields = array_merge($this->fields, $add_fields);
$this->add_fields = $add_fields;
}
Where the $table = ‘tree’ is hard-coded. I tried removing it (so just $table), and passing ‘tree’ through as
$jstree = new json_tree('tree');
but that didn’t work. Any ideas/help would be greatly appreciated!
To those curious, I had completely forgotten that server.php also includes a jstree (I had also initiated it in my left menu). For those interested, or who need a conditional based tree, what I did was:
function __construct($table, $fields = array(), $add_fields = array("title" => "title", "type" => "type"))if($_SESSION['condition'] == 1) { $jstree = new json_tree("tree");}else { $jstree = new json_tree("tree_users");}
I hope this helps someone!