HOW TO use TreeMenu to select a file?

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

Moderators: ne_moj, zewa, Milton, vadimako, ne_moj, zewa, Milton, vadimako

sferraro
Senior
Senior
Posts: 29
Joined: Sep 30th, '09, 04:14

HOW TO use TreeMenu to select a file?

Postby sferraro » Dec 16th, '11, 22:58

Hi:

I would like to use TreeMenu as a file manager to select a file for editing or deleting from a folder on my website from another web page that i have created. Currently, i can use it to view the contents of text files by using "treeMenu->BuildFromFolder("$folder");" and "$treeMenu->ShowTree();" while using the "$treeMenu->SetPostBackMethod("ajax");" method. Is there any way to get and store the path and name of the selected file to a PHP memory variable? If so, please let me know how I can do it.

Thank you.

SPF

Milton
Senior
Senior
Posts: 31
Joined: Jan 14th, '10, 14:17

Re: How to use TreeMenu to select a file

Postby Milton » Dec 19th, '11, 22:26

I suppose you're using AJAX as a postback method.

Every time a node is clicked, __tmPostBackAjax JavaScript function is called (it's in the js/script.js file). The second parameter is file's name and path and you can get it from there. Storing it to a PHP memory variable is not supported yet.

Hope that helps.

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

Re: How to use TreeMenu to select a file

Postby vankev » Dec 19th, '12, 11:03

By getting the value of filename could you then do what you wanted? These are the modifications I made to get the full path of the file selected from the treemenu (dynamically updates) -- using post:

In treemenu.class.php:
1. Create a new private data member in class TreeMenu

Code: Select all

private $selectedPath;


2. Create getters and setters for your new data member

Code: Select all

public function GetSelectedPath()
{
    $temp = str_ireplace("\\", "/", $this->selectedPath());
    return $temp
}

public function SetSelectedPath($path)
{
    $this->selectedPath = $path
}

3. In the function ShowContent() in the class TreeMenu, scroll down to if(selectedNode !=null)

Code: Select all

if($selectedNode !=null)
{
    //disable the treeMenu from displaying the selected file in a separate container
    //$output.= $selectedNode->ShowContent($this->GetDebug()); --> by commenting out this code, the treemenu no longer displays the selected node in a spearate container, may be useful if you want to select files, as clicking .php files normally invokes their execution by the TreeMenu class or Node class
    $this->SetSelectedPath($selectedNode->GetFile());
}


Now that you have created the data member and have access to it, in the php file that contains the instantiation of the treeMenu, you can access the selected file by using:

Code: Select all

 
$treeMenu->getSelectedPath()


Now you can access the path of the selected file, and do what you will with it.

Hope this helps,
Kevin

fullcrackfile
Newbie
Newbie
Posts: 1
Joined: Jan 5th, '16, 11:59
Location: United States
Contact:

Re: HOW TO use TreeMenu to select a file?

Postby fullcrackfile » Feb 29th, '16, 05:50

Thanks for the solution . ..


Return to “ApPHP TreeMenu”