Jump to content

Recommended Posts

Hi,

I just started with php and am trying to build my first webpage with it. So I got the popular TreeMenuXL which as far as I know uses php to generate dynamic html. Now the page I was aming for uses php to generate the pages (obviously..), but when use a function call to generate the menu it becomes static. Now I tried making a class holding the menu (and creating the menu in the constructor) cause I thought, an instance of an object cant be static.. But no game. The menu uses the following code to be created (might not say much but it shows where instances are created..) :

[code]
require_once("TreeMenuXL.php");
 
$nodeProperties = array("cssClass"=>"auto");
  $menu03  = new HTML_TreeMenuXL();
  $node03  = new HTML_TreeNodeXL("INBOX", "#", $nodeProperties);
  $nx = &$node03->
    addItem(new HTML_TreeNodeXL("A Folder", "#link1", $nodeProperties));
  $nx = &$nx->
      addItem(new HTML_TreeNodeXL("Nested Folder", "#link2", $nodeProperties));
  $nx = &$nx->
        addItem(new HTML_TreeNodeXL("Deeper ...", "#link3", $nodeProperties));
  $nx = &$nx->
          addItem(new HTML_TreeNodeXL("... and Deeper", "#link4", $nodeProperties));

  $node03->addItem(new HTML_TreeNodeXL("deleted-items", "#link5", $nodeProperties));
  $node03->addItem(new HTML_TreeNodeXL("sent-items",    "#link6", $nodeProperties));
  $node03->addItem(new HTML_TreeNodeXL("drafts",        "#link7", $nodeProperties));     
  $node03->addItem(new HTML_TreeNodeXL("spam",          "#link8", $nodeProperties));     
   
  $menu03->addItem($node03);
  $menu03->addItem(new HTML_TreeNodeXL("My Stuff",      "#link9", $nodeProperties));
  $menu03->addItem(new HTML_TreeNodeXL("Other Stuff",   "#link10", $nodeProperties));
  $menu03->addItem($node03);

$example032 = &new HTML_TreeMenu_DHTMLXL($m, array("images"=>"TMimagesAlt"));
  $example032->printMenu();
[/code]



Now if I put this directly on the webpage manually everything works out fine. But if I put it say like this:

[code]
<?php makeMenu(); ?>


<?php function makeMenu(){

(the above code)

?>
[/code]

It becomes static! And this applies (like I allready said) when I use classes to. What to do?

Thanks so much in advance for any help you can give me.
Link to comment
https://forums.phpfreaks.com/topic/14247-concerning-dynamic-and-static-context/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.