This topic is locked

Tree view

2/4/2010 8:18:10 AM
PHPRunner Tips and Tricks
P
Pavel Nefyodov author

PHPRunner 5.1 version

Tree view question
I was trying to get flexible tree menu view working.
Initially, I have created tree-like menu in menu builder then I started to change
displaymenu.php.
Instead of this code:

// create menu nodes arr
$menuNodes = array();
$menuNode = array();
$menuNode["name"] = "Root";
$menuNode["nameType"] = "Text";
$menuNode["id"] = "1";
$menuNode["parent"] = "0";
$menuNode["style"] = "";
$menuNode["href"] = "";
$menuNode["table"] = "";
$menuNode["type"] = "Group";
$menuNode["linkType"] = "None";
$menuNode["pageType"] = "List";
$menuNode["openType"] = "None";

// set title
$menuNode["title"] = "Root";

$menuNodes[] = $menuNode;
$menuNode = array();
$menuNode["name"] = "";
$menuNode["nameType"] = "Text";
$menuNode["id"] = "2";
$menuNode["parent"] = "1";
$menuNode["style"] = "";
$menuNode["href"] = "";
$menuNode["table"] = "dbo.New_Folders";
$menuNode["type"] = "Leaf";
$menuNode["linkType"] = "Internal";
$menuNode["pageType"] = "List";
$menuNode["openType"] = "None";

// set title
$menuNode["title"] = "New Folders1";

$menuNodes[] = $menuNode;


Where table "New_Folder" is


ID Title description parent


1 Root Root folder NULL
2 New Folder First folder 1
I inserted

$menuNodes = array();

global $conn;
$stringSQL = "SELECT [ID] as ID
,[title] as title
,[description] as description
,iSNULL([parent], 0) as parent
FROM [FAQ].[dbo].[New_Folders] order by id, parent" ;

$rs=db_query($stringSQL,$conn);

while ($row = db_fetch_array($rs))
{
$menuNode = array();
$menuNode["name"] = $row['title'];
$menuNode["nameType"] = "Text";
$menuNode["id"] = (string) $row['ID'];
$menuNode["parent"] = (string) $row['parent'];
$menuNode["style"] = "";
$menuNode["href"] = "";
$menuNode["table"] = "";
$menuNode["type"] = "Group";
$menuNode["linkType"] = "None";
$menuNode["pageType"] = "List";
$menuNode["openType"] = "None";
$menuNode["title"] = $row['title'];
$menuNodes[] = $menuNode;
}


So basically I wanted my tree structure populated from the database.
It didn't work even though connection to database worked properly.
The thing is, when I have created initially only 2 nodes it worked for two nodes from my table "New_Folder"
but other entries were ignored.
Also I created long menu tree (from user interface) that worked, but when I inserted the code (everything between
"$menuNodes = array();" and "$menuNodes[] = $menuNode;" from displaymenu.php) into the same project
from which I have deleted couple of nodes, it didn't work.
Does PHPRunner 5.1 store the data about tree structure somewhere else (except for displaymenu.php)?

R
rgfischerjr 3/15/2010



Does PHPRunner 5.1 store the data about tree structure somewhere else (except for displaymenu.php)?


Pavel - did you find the answer to this question?

P
Pavel Nefyodov author 4/8/2010



Pavel - did you find the answer to this question?



Yes, thank you. Eventually I have created tree structure populated from the database.