Milonic provide full featured pull down web menus for some of the worlds largest companies
click here to see what it can do for you

Download Milonic DHTML Menu
Buy Milonic DHTML Menu

Back To Start Of Archive
Taken From The Forum: Help & Support for DHTML Menu Version 5+
Forum Topic: Click to view post
Last Updated: Saturday July 14 2012 - 06:07:28

Is PHP within the menu_array.js file possible?


Poster: sdit
Dated: Friday May 14 2004 - 13:45:29 BST

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


Poster: John
Dated: Saturday May 15 2004 - 2:04:08 BST

Exactly what version of the menu are you running? It appears to be v3.


Poster: kevin3442
Dated: Saturday May 15 2004 - 2:14:47 BST

Hi Simon,

(1) It looks like you're missing the closing parenthesis for the echo. I assume you want
Code:
<? 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


Poster: sdit
Dated: Tuesday May 18 2004 - 9:55:00 BST

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:
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 :(


Poster: Andy
Dated: Tuesday May 18 2004 - 10:08:25 BST

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


Poster: sdit
Dated: Tuesday May 18 2004 - 12:45:24 BST

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


Poster: kevin3442
Dated: Wednesday May 19 2004 - 0:16:25 BST

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