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

Changing menu item according to login state

Poster: chet
Dated: Monday May 23 2005 - 1:31:15 BST

Hi I am integrating milonic menu (follow scroll type menu) with my oscommerce shop.

The thing I would like to do is have a menu item which if a customer wishes to log in, the menu item reads "log in" (default) and if logged in, this then changes to "log out" and links to a file called logoff.php

Is this possible? - there are two associated php files for each function but how to add the logic or where to find it and implement it, i don't know.

Maybe someone familiar with oscommerce can help here.


Poster: kevin3442
Dated: Monday May 23 2005 - 4:45:18 BST

Hi Chet,

I'm not too familiar with php or oscommerce, but I imagine the process would be similar to how you might do it with asp.

Most people's menu_data file is normally a static .js file. But you can use php commands in it by sending it through the php parser when the page is served; just name the file menu_data.php instead of menu_data.js. Now you can include php conditionals in with the menu's javascript. Like I said, I'm not too familiar with php, but I imagine that there must be a php session variable that you can test, like a UserName, to see if the user is logged in or not. If the user is not logged in, then generate the aI() menu item for logging in. If the user is logged in, generate the aI() item for logging out instead. In asp, I do something similar like so in menu_data.asp:

with(milonic=new menuname("main")){
  <%if session("UserName") & "" = "" then%>
    aI("text=Log In;url=login.asp;");
    aI("text=Log out;url=logout.asp");
  <%end if%>
  aI("text=About Us;url=aboutus.asp");
  aI("text=Contact Us;url=contactus.asp");

The <%if...%> tests to see if the UserName session variable is blank. If it is blank, then the user is not logged in, and so the aI() item for logging in is generated. The <%else%> is true only if UserName isn't blank, which must mean that the user is logged in, so generate the aI() menu item for logging out.

This is in asp, by maybe that'll help you come up with similar php code.

Hope that helps,


Poster: chet
Dated: Monday May 23 2005 - 11:49:03 BST

Thanks Kevin,

I think I have found the detect part by looking at a login box module.

(!tep_session_is_registered('customer_id')) {

but I dont think Ive the knowledge to implement the php within javascript.

could I just edit the menu_data.js javascript to include a php code i.e. put it inbetween <?php & ?> to mark the start and end of the php.
I've tried something like this but failed!