Hello,
I want to build a tree using the PHP connector. For this exemple i use the sample code of the tree connector. All i want to do is implement some “if’s” on each one of the cases.
- How can i customize my tree depending of the ID’s loaded from de database. I want to change the item colour, remove the item (don’t show him) or replace him by a item with an ID and text specified by me?
- How can i change the query that i will execute depends of the parameter that i receive in the URL?
Here is my PHP code:
[code] require_once(“…/config.php”);
$res=mysql_connect($mysql_server,$mysql_user,$mysql_pass);
mysql_select_db($mysql_db);
require("../../codebase/treemultitable_connector.php");
function custom_format($item){
if ($item->get_value("project_id")>1){
if ($item->get_value("project_id")=2){
$item->set_image("lock.gif"); //Change the icon image
$item->set_kids(false); //Prevent the existence of kids/parents
}else{
if($item->get_value("project_id")=3){
//replace the item by Name=NewProject and ID=100
}else{
//Delete item
}
}
}else{
//Show normal item (without any change)
}
}
$tree = new TreeMultitableConnector($res);
$tree->enable_log("temp.log",true);
$tree->setMaxLevel(3);
$level = $tree->get_level();
switch ($level) {
case 0:
$tree->event->attach("beforeRender",custom_format());
$tree->render_table("projects","project_id","project_name","","");
break;
case 1:
//If an URL parameter is set i want to run a diffrent query with a specific parameter
if($_REQUEST['specific_team']>0){
$team = $_REQUEST['specific_team'];
$tree->render_sql("SELECT teams.team_id, teams.team_name, project_team.project_id FROM teams WHERE team.team_id = $team INNER JOIN project_team ON teams.team_id=project_team.team_id", "team_id", "team_name", "", "project_id");
}else{
$tree->render_sql("SELECT teams.team_id, teams.team_name, project_team.project_id FROM teams INNER JOIN project_team ON teams.team_id=project_team.team_id", "team_id", "team_name", "", "project_id");
}
break;
case 2:
$tree->render_table("developers", "developer_id", "developer_name", "", "developer_team");
break;
case 3:
$tree->render_table("phones", "phone_id", "phone", "", "phone_developer");
break;
}[/code]
I add some comments in the php file where i want to do the chenges:
//Change the icon image
//Prevent the existence of kids/parents
//replace the item by Name=NewProject and ID=100
//Delete item
//If an URL parameter is set i want to run a diffrent query with a specific parameter
NOTES: The config is working, and the html is working to.
HTML:
[code]
Multitable connector GetItemID [/code]