Categories > TinyButStrong general >

I am confused about exactly what "global" means

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: garyro
Date: 2005-02-07
Time: 00:33

I am confused about exactly what "global" means

In my php script

if($_REQUEST['action'] == 'noaction') {
    $menuModeImage = 'folder.gif';
    $menuModeAction = 'edit';
    $menu = BuildMenu();
}

In my template file

</head>
<body>
<p><b>Content Tree <a href='menuFrame.php?action=[var.menuModeAction]'>
                   <img src='./imagestree/[var.menuModeImage]' title='Add a New Item' alt='New' border='0'/>
                   </a></b></p>

[var.menu;htmlconv=no]

</body>
</html>


results in the following error for all three variable

TinyButStrong Error (Merge PHP global variables): Can't merge [var.menuModeAction] because there is no PHP global variable named 'menuModeAction'.

If I remove the if statement it is fine.

I assume this has something to do with "globals" although from the standpoint of PHP the if statement should make no difference neither of these are 'global'

So what am I missing.

If I can't set variables in my php scripts and then have them reflected in the templates I cant see much use in using TBS

Thanks
By: Skrol29
Date: 2005-02-07
Time: 00:59

Re: I am confused about exactly what "global" means

Hi Garyro,

There are not global variables because they are not variables at all.
It seems that when your if() statement is not verified, then the variables are never set.

I suggest that you use parameter 'noerr' or that you use the following code:
if($_REQUEST['action'] == 'noaction') {
  $menuModeImage = 'folder.gif';
  $menuModeAction = 'edit';
  $menu = BuildMenu();
} else {
  $menuModeImage = '';
  $menuModeAction = '';
  $menu = '';
}
By: garyro
Date: 2005-02-07
Time: 01:11

Re: I am confused about exactly what "global" means

oops!
I guess I shouldn't be programming so late at night. Your answer was not my problem but it is my own bug. I do aplogize for my own stupidity