Is PHP within the menu_array.js file possible?

Having problems with DHTML Menu? There is usually somebody here who knows the answer.
Post Reply
sdit
Beginner
Beginner
Posts: 4
Joined: Fri May 14, 2004 1:31 pm

Is PHP within the menu_array.js file possible?

Post by sdit »

I wan to be able to create a menu that will direct users to different locations depending on who they are. The site is password protected so that I know who is using the page.

I want to do something like...

Code: Select all

aI("text=Jobs;url=/cgi-bin/toplevel.cgi?page=jobs&user=<? echo($_SERVER['PHP_AUTH_USER'];?>;target=realtime;sourcename=realtime;;seaparator=1")
When I try this syntax the menu goes all wrong.

The menu_array.js is being called within a .php file, so it will go throught the PHP interpretor.

Anyone any ideas how I might achieve this, or is it just a syntactical error?

Any help appreciated. Can't post a URL as this is on an intranet system.

Thanks,

Simon
User avatar
John
 Team
 Team
Posts: 5967
Joined: Sun May 19, 2002 8:23 pm
Location: Phoenix, AZ
Contact:

Post by John »

Exactly what version of the menu are you running? It appears to be v3.
John
User avatar
kevin3442
Milonic God
Milonic God
Posts: 2460
Joined: Sat Sep 07, 2002 12:09 am
Location: Lincoln, NE
Contact:

Post by kevin3442 »

Hi Simon,

(1) It looks like you're missing the closing parenthesis for the echo. I assume you want

Code: Select all

<? echo($_SERVER['PHP_AUTH_USER'];) ?>
(2) Not sure what sourcename=realtime; is for (perhaps a leftover of sourceframe in the v3 menu???). What is it you're going after here? As far as I know, sourcename is not a menu item property. But if it was, you'd have an extra semicolon after it.

(3) separator is also not a menu poperty, so I'm not sure what you're going for with separator=1 (althouh that syntax was used in the v3 menu to indicate the presence and size of a separator, it's not used in v5). Even so, although a minor syntactical consideration, you should have a semicolon after every menu item proprety assignment in the aI() string, including the last one.

(4) Also minor... a semicolon ending the js line.

If you can describe what it is you're hoping to do with sourcefile and sparator, we might be able to suggest the appropriate menu property.

Hope that helps,

Kevin
sdit
Beginner
Beginner
Posts: 4
Joined: Fri May 14, 2004 1:31 pm

Post by sdit »

Hi,

I'm using v5.18

The sourcename was related to a v3 iframe issue. I guess the separator is a hangover from v3 as well. I have changed it to separatorsize.

The missing parenthesis was a typo.

The code is now

Code: Select all

aI("text=Jobs;url=/cgi-bin/toplevel.cgi?page=jobs&user=<? echo($_SERVER['PHP_AUTH_USER']);?>;target=realtime;separatorsize=1");
and still doesn't do what I wanted :(
User avatar
Andy
Milonic
Milonic
Posts: 3308
Joined: Sun May 19, 2002 8:23 pm
Location: Menu Developer
Contact:

Post by Andy »

The code works fine for me.

Can you echo the PHP_AUTH_USER to the screen?

Also, you are logged in I take it?

-- Andy
sdit
Beginner
Beginner
Posts: 4
Joined: Fri May 14, 2004 1:31 pm

Post by sdit »

Got it...

Renamed the JS script to be .php but still kept it as a script include in the main php document.

Don't know why this works, but it does. Must run through the php compiler before including the .js files, but is called again when the JS script file is called .php

Thanks for the help.

Simon
User avatar
kevin3442
Milonic God
Milonic God
Posts: 2460
Joined: Sat Sep 07, 2002 12:09 am
Location: Lincoln, NE
Contact:

Post by kevin3442 »

sdit wrote:Got it... Renamed the JS script to be .php but still kept it as a script include in the main php document. Don't know why this works, but it does....
If your menu_data file contains php code, then you have to name the file with a .php extension so that the web server will parse it through the php server. Otherwise, the php code would be sent in raw form to the client, which would try to process it as js code... resulting in errors and no menu.

Glad it works,

Kevin
Post Reply