I know I am being stupid but ...

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

jim1506
Junior
Junior
Posts: 23
Joined: Aug 28th, '10, 10:59
Contact:

I know I am being stupid but ...

Postby jim1506 » Sep 12th, '10, 09:16

I have a tree and I simply want the user to be taken to a page "detail.php?id=" plus the name of the node. Can some enlightment me please for the code to use?
Last edited by jim1506 on Sep 12th, '10, 09:32, edited 1 time in total.

jim1506
Junior
Junior
Posts: 23
Joined: Aug 28th, '10, 10:59
Contact:

Re: I kn ow I am being stupid but ,,,

Postby jim1506 » Sep 12th, '10, 09:32

Sorry I should have given some sample code:


$treeMenu->Debug(true);
$treeMenu->SetPostBackMethod("get");
$sometext=$treeMenu->AddNode("Some Text","test.php");



I just want to know why it does not fire off as a link to test.php

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

Re: I know I am being stupid but ...

Postby Milton » Sep 12th, '10, 16:56

jim1506 wrote:I have a tree and I simply want the user to be taken to a page "detail.php?id=" plus the name of the node. Can some enlightment me please for the code to use?

You should use 'OpenNewWindow' function. For example:

Code: Select all

$treeMenu = new TreeMenu();
$name="node_name";
$newNode=$treeMenu->AddNode($name,"detail.php?id=".$name);
$newNode->OpenNewWindow(true);

jim1506
Junior
Junior
Posts: 23
Joined: Aug 28th, '10, 10:59
Contact:

Re: I know I am being stupid but ...

Postby jim1506 » Sep 12th, '10, 18:12

Thanks for this but it is not working. Here is my sample code:

<head>
</head>
<body>
<?php
define("TREEMENU_DIR",'includes/treemenu/');
include(TREEMENU_DIR."treemenu.class.php");
$treeMenu = new TreeMenu();
//$treeMenu->Debug(true);
$treeMenu->SetStyle("vista");
$name="name1";
$newNode=$treeMenu->AddNode($name,"detail.php?id=".$name);
$newNode->OpenNewWindow(true);
$name2="name2";
$newNode=$treeMenu->AddNode($name2,"detail.php?id=".$name2);
$newNode->OpenNewWindow(true);
$treeMenu->ShowTree();
?>
</body>

and I have uploaded it to

http://79.170.40.40/teamworkphoto.com/treetest2.php


What I am doing wrong?

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

Re: I know I am being stupid but ...

Postby Milton » Sep 12th, '10, 19:54

I've tried your code on my server and it works fine.
It looks like the problem is that detail.php file can't be found. It must be located in the same folder as the main PHP file. If you still have problems please comment this row:

Code: Select all

if(strpbrk($filename,self::$bad_chars) || !file_exists($filename))

('AddNodeAction' function, 'TreeMenu' class, 'treemenu.class.php' file)
Did it help?

jim1506
Junior
Junior
Posts: 23
Joined: Aug 28th, '10, 10:59
Contact:

Re: I know I am being stupid but ...

Postby jim1506 » Sep 12th, '10, 19:59

Thanks. I never actually created the detail file as I expected just to see a 404 error.

If I wanted it to call a JavaScript function ? eg open a colorbox or something? I would appreciate this.

This is a great product but you need a little more documentation!

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

Re: I know I am being stupid but ...

Postby Milton » Sep 13th, '10, 20:07

jim1506 wrote:If I wanted it to call a JavaScript function ? eg open a colorbox or something? I would appreciate this.

Code: Select all


window.onload = function(){
   document.getElementById("textXXX").onclick = function () {
       alert("Inside my heart is breaking \\ My make-up may be flaking \\ But my smile still stays on");
}
}

XXX is node's id. You can get it using GetId() function:

Code: Select all

echo $node->GetId();


Return to “ApPHP TreeMenu”