Build nodes from folder paths returned from database

Discuss everything related to ApPHP TreeMenu. Any questions related to the ApPHP TreeMenu developing or using should be posted to this forum.

Moderators: alexandrleonenko, Milton

vankev
Newbie
Newbie
Posts: 3
Joined: Dec 18th, '12, 10:08

Build nodes from folder paths returned from database

Postby vankev » Dec 18th, '12, 14:55

Hi,

I have currently written a script to query a MSSQL database and return the full relative path of a folder if a user has security permissions to see that folder. I want to build the treemenu structure around each of the folders that is returned by this query. In essence, I want each folder to be a primary node, with the plus expanding the node to see the contents of that folder (which may contain files and/or subfolders). I am currently using the $treemenu->BuildNodeFromFolder() function, but this seems to create the node one level down, in that the treemenu creates nodes on the screen of the specified folder's subfolders and files.

Any ideas on how to achieve this would be welcomed.

Kind regards,
Kevin
Attachments
tree.jpg
This is a screenshot of what my code is currently producing on the treemenu structure, all of these files are within the folder I wanted to be one node
tree.jpg (73.82 KiB) Viewed 2406 times

vankev
Newbie
Newbie
Posts: 3
Joined: Dec 18th, '12, 10:08

Re: Build nodes from folder paths returned from database

Postby vankev » Dec 19th, '12, 10:47

I have solved this issue. They key is to create nodes before trying to build from a folder. My SQL script returns: ID, FolderName, FolderPath.

Code:

Code: Select all

$result = dbConn->dbInst->query($sql);
$result->setFetchMode(PDO::FETCH_ASSOC);

foreach ($result as $row)
{
    $temp = $treeMenu->AddNode($row["FolderName"]);
    $treeMenu->buildNodeFromFolder($temp, $row["FolderPath"], true, false);
}

$treeMenu->ShowTree();
$treeMenu->ShowContent();

pipobucket
Newbie
Newbie
Posts: 2
Joined: Mar 18th, '15, 05:11

Re: Build nodes from folder paths returned from database

Postby pipobucket » Mar 18th, '15, 05:15

I read a very useful simplification can be used in everyday reality.


Return to “ApPHP TreeMenu”