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:34
Help wanted!
Poster: forjaes
Dated: Monday June 4 2007 - 12:38:41 BST
I'm new in PHP programing... I'm doing a work for college and use the milonic menu 5.774.
I have a login page in php that control the access of the site, and once logged i'd like to enable a menu to see the user info.
I search for help with google and here... Found the exact same problem i have but wasn't enable to solve it.
The menu is in a folder ./menu/ with all files, in the root folder.
I made all the changes in the path.
All i want is passing the value of $session->username to the menu in order to display all info.
Is like this:
In .php file...
</head>
<body>
<SCRIPT language=JavaScript src="./menu/milonic_src.js" type=text/javascript></SCRIPT>
<script language=JavaScript>
if(ns4)_d.write("<scr"+"ipt language=JavaScript src=./menu/mmenuns4.js><\/scr"+"ipt>");
else _d.write("<scr"+"ipt language=JavaScript src=./menu/mmenudom.js><\/scr"+"ipt>");
</script>
<SCRIPT language=JavaScript src="./menu/menu_data2.js" type=text/javascript></SCRIPT>
<div id="current_flag">
...
...
</body>
</html>
You see that i change the name of menu_data.js to menu_data2.js
in menu_data2.js
with(milonic=new menuname("User Info")){
overflow="scroll";
style=SubmenuStyle;
aI("text=Ver Perfil;url=userinfo.php?+"<? echo user=$session->username?>";");
aI("text=Change Profil;url=editinfo.php;");
}
My problem is that no value is passed in the first link...
I tried every thing like others...
Change .js to .php, print...
None works...
Please, maybe it's a stupid thing but i'd really like to know what i'm doing wrong.
Thx a lot.
Poster: Andy
Dated: Wednesday June 6 2007 - 11:24:03 BST
Hi,
Youll need to change the file extension from .js to .php - Without the .php extension the server will not know how to parse the file and will ignore all PHP actions.
HTH,
Andy
Poster: forjaes
Dated: Wednesday June 6 2007 - 12:07:33 BST
Andy wrote:
Hi,
Youll need to change the file extension from .js to .php - Without the .php extension the server will not know how to parse the file and will ignore all PHP actions.
HTH,
Andy
Youll need to change the file extension from .js to .php - Without the .php extension the server will not know how to parse the file and will ignore all PHP actions.
HTH,
Andy
In the folder i guess..??
What about the:
<script type="text/javascript" src="./menu/menu_data2.js"></script> in all .php pages with menu???
I tried but it's not working.
The all menu disapeared...
I got it working know... but just one time!!!
I declare a variable in main.php like this:
...
<body>
<script>
var user = '<? echo $session->username ?>';
</script>
<script type="text/javascript" src="./menu/milonic_src.js"></script>
<script type="text/javascript" src="./menu/mmenudom.js"></script>
<script type="text/javascript" src="./menu/menu_data2.js"></script>
...
and in menu_data2.js i got:
...
var user;
...
with(milonic=new menuname("Perfil Utilizador")){
overflow="scroll";
style=SubmenuStyle;
aI("text=Ver Perfil;url=userinfo.php?user="+user+";");
aI("text=Alterar o Perfil;url=useredit2.php;");
}
...
after logged in the first time it work like a charme:
http://localhost/novabase/pt/userinfo.php?user=marcio
and show the user info.
But the second consecutive try it says:
http://localhost/novabase/pt/userinfo.p ... =undefined
and show nothing.
How do i keep the value of the var 'user' in it??
What's worng with that...?? Or with me???
thx for helping.
Poster: Ruth
Dated: Wednesday June 6 2007 - 14:51:40 BST
Hi,
I think Andy is saying you need to change the menu_data2.js to menu_data2.php. By changing the extension to php you are telling the server to parse the php commands in the menu_data file. If you do not change the menu_data.js file to a php file then the server just ignores any php 'commands' you have in that file because it is parsing it at js and doesn't know what to do with the php commands.
Ruth
Poster: forjaes
Dated: Wednesday June 6 2007 - 15:00:02 BST
Ruth wrote:
Hi,
I think Andy is saying you need to change the menu_data2.js to menu_data2.php. By changing the extension to php you are telling the server to parse the php commands in the menu_data file. If you do not change the menu_data.js file to a php file then the server just ignores any php 'commands' you have in that file because it is parsing it at js and doesn't know what to do with the php commands.
Ruth
I think Andy is saying you need to change the menu_data2.js to menu_data2.php. By changing the extension to php you are telling the server to parse the php commands in the menu_data file. If you do not change the menu_data.js file to a php file then the server just ignores any php 'commands' you have in that file because it is parsing it at js and doesn't know what to do with the php commands.
Ruth
I did understood that part. I rename menu_data2.js to menu_data2.php in my folder menu. In my main.php i includes the 3 javascript files
<script type="text/javascript" src="./menu/milonic_src.js"></script>
<script type="text/javascript" src="./menu/mmenudom.js"></script>
<script type="text/javascript" src="./menu/menu_data2.js"></script>
So it becomes like that??
<script type="text/javascript" src="./menu/milonic_src.js"></script>
<script type="text/javascript" src="./menu/mmenudom.js"></script>
<script type="text/javascript" src="./menu/menu_data2.php"></script>
That makes no sense to me...
How do i include then the menu in all my .php files????
thx.
Poster: Ruth
Dated: Wednesday June 6 2007 - 15:11:26 BST
Hi,
If you look at the main site for Milonic you will see the call for the menu_data file is
Code:
<script src="/menu_data.php" type=text/javascript></script>
I don't do php, but I'm assuming when you say how do you include it in all your php files, you mean your php pages? If that's the case, then in whichever part becomes the section that has the calls for the menu file, that is where you put the call for the menu_data.php. It has to have that extension to parse php commands. So, whichever part creates the body tag and the call for the menu would be where you put it, as far as I know, if that is your main.php then that's where it goes.
Code:
<body><script type="text/javascript" src="./menu/milonic_src.js"></script>
<script type="text/javascript" src="./menu/mmenudom.js"></script>
<script type="text/javascript" src="./menu/menu_data2.php"></script>
<script type="text/javascript" src="./menu/mmenudom.js"></script>
<script type="text/javascript" src="./menu/menu_data2.php"></script>
The other program files stay as js, since they are the js that controls the menu, the menu_data is the only one that gets changed to php. There is a php menu in your download.
Ruth
Poster: John
Dated: Wednesday June 6 2007 - 16:13:46 BST
Bottom line is - you can't call a file that's not there! If you leave the actual file name on the server as menu_data2.js, but change your calls to menu_data2.php (which you must do in this case), the system will - obviously - never find that file.
Side note - the _data file, and only the _data file, can have any extension you need; e.g., .js, .cfm. .php, .asp, etc., etc.