Jump to content

Archived

This topic is now archived and is closed to further replies.

sgw

Concerning dynamic and static context

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.

Share this post


Link to post
Share on other sites

×

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.