Hi Maz, Justin,
Don't know if you want to do this here, or email, so I posted this to both:
Unfortunately, I am not a php user. I have dabbled, but have yet to really do anything substantial with it. So this might be the blind leading the blind.
It seems that what is needed is a way to set the userIsMember js variable from the php script. Can you create a global variable in php? If so, suppose you call it $userStatus. $userStatus would be set to true or false (1 or 0 will do) in the php login script... 1 if logged in, 0 if not. You could probably then use a php echo to get the value of $userStatus into the js userIsMember variable. Maybe something like this:
Code: Select all
<script language=javascript>
var userIsMember = <?php echo $userStatus ?>;
<script>
-or-
Code: Select all
<script language="javascript">
<?
echo("var userIsMember = ".$userStatus.";");
?>
</script>
If you're generating the entire page with php, I suppose you'd have to echo the <script> tag lines as well. These script lines could be included in the main page or, probably, into the top of the menu_data.js file (without the <script> tags, of course).
Another possibility might be to have the php script store the value of $userStatus in a hidden form field, then set the value of the js variable userIsMember from the contents of that hidden field; using the hidden field as a temporary holding place to pass the data between php and js. I have no idea how to set a hidden field's value from php, but if you can do that, then I can tell you how to read the value out of the field using js. I might try the more direct methods above first.
Kevin
P.S. It occurs to me that you could also generate the entire menu_data script from php, which might be the easier way to go if you're going to be doing much more dynamic menu generating.