Jump to content


Concerning dynamic and static context

  • Please log in to reply
No replies to this topic

#1 sgw

  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 10 July 2006 - 11:59 PM


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..) :

 $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(new HTML_TreeNodeXL("My Stuff",      "#link9", $nodeProperties)); 
  $menu03->addItem(new HTML_TreeNodeXL("Other Stuff",   "#link10", $nodeProperties)); 

$example032 = &new HTML_TreeMenu_DHTMLXL($m, array("images"=>"TMimagesAlt")); 

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

<?php makeMenu(); ?>

<?php function makeMenu(){

(the above 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.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users