#1
  1. No Profile Picture
    Standards User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Posts
    146
    Rep Power
    12

    Including Menu In Certain Directories


    I'm including a template on all pages in a site. In the template I have a menu. What I'd like is to have a different menu displayed if I'm in a different directory.
    Something along the lines of:

    If path is /mainsite Then
    Regular Menu
    If path is /admin Then
    Admin Menu

    Just not sure about how to go about getting there. My first thought was to use the PATH_INFO server variable, but that returns the page name too.
    Any suggestions?
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Posts
    138
    Rep Power
    12
    For getting a path use server.Mappath()

    depending how you setup your website you can also use server side inludes

    ie.

    <!--#include file="page.asp"-->
    and
    <!--#include virtual="page.asp"-->

    The virtual include will require extra server setup to work properly
    --

    ngibsonau
  4. #3
  5. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Location
    Canada - Egypt
    Posts
    60
    Rep Power
    12
    you could also use the

    Request.ServerVariables("SCRIPT_NAME")

    which will give a full path of the current page, starting at the root of the server "/" and you could use that to parse it and put all the if staments that u want

    I hope this is of any help.
    I hope this is of any help to anyone.

    Yassoor
    http://www.WebsitesCreation.ca
  6. #4
  7. No Profile Picture
    Standards User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Posts
    146
    Rep Power
    12
    Thanks guys.

    Looks like I really need to practice my If Then Statements. I'm trying to do this without a page name, because there are many pages in each directory.

    Although not the exact method I hoped to use, I did get the intended effect by just creating a variable called ShowMenu, then setting that to 1 on each page I want the menu to display on.

    If you could show me a better way than I've done, it would be appreciated. Thanks again for your suggestions.
  8. #5
  9. No Profile Picture
    Overly white
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Location
    Fresno, CA
    Posts
    83
    Rep Power
    12
    Try this code on for size.
    Code:
    <%
    	dim strPath
    	dim intPos
    	strPath = lcase(Request.ServerVariables("SCRIPT_NAME"))
    
    	intPos = Instr(1,strPath,"/admin/")
    
    	If intPos > 0 Then
    		response.write("Admin")
    	else
    		response.write("Other")
    	end if
    %>

IMN logo majestic logo threadwatch logo seochat tools logo