Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: Better way?

  1. #1
    New to the CF scene
    Join Date
    Apr 2006
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Better way?

    Hi,

    I'm a bit stuck as I'm trying to achieve this:
    From the navigation link on the left I'd like the appropriate page to be loaded in to the content area (to the right) as include files...

    Do I use the Select Case or the If statements Or do I just create a template and reload the relevant page each time? (there are about 15 different pages) OR is there a better way?

    Please assist and TIA - hope I've explained it well .

    (NOTE: The Navigation link is also an include file)

  • #2
    Senior Coder
    Join Date
    Nov 2002
    Location
    North-East, UK
    Posts
    1,265
    Thanks
    0
    Thanked 0 Times in 0 Posts
    How are you including? Are you using server side includes, Server.Execute, XMLHTTP or another method?


    If they are all in the same folder then you can use request.querystring, check if the file exists then include it or execute it.
    Code:
    	<%
    	If Len(Request.QueryString("page")) > 0 Then
    		filePath = Server.MapPath(".\") & "\" & Request.QueryString("page")
    		Set fs=Server.CreateObject("Scripting.FileSystemObject")
    	
    			If (fs.FileExists(filePath))=true Then
    				Server.Execute(Request.QueryString("page"))
    			Else
    				Response.Write("Error: " & Request.QueryString("page") & " not found")
    			End If
    	
    		set fs=nothing
    	End If
    %>
    Code:
    <%
    	If Len(Request.QueryString("page")) > 0 Then
    		page = Request.QueryString("page")
    		fileName = Server.MapPath(".\") & "\" & page
    		Set fs=Server.CreateObject("Scripting.FileSystemObject")
    	
    			If (fs.FileExists(fileName))=true Then
    				'Server.Execute(Request.QueryString("page"))
    				parts = Split(Request.ServerVariables("PATH_INFO"),"/")
    					For x=0 To Ubound(parts)-1
    						path = path & parts(x) & "/"
    					Next 
    				url = "http://" & Request.ServerVariables("HTTP_HOST") & path & page
    				Response.Write url
    				set http_obj=server.CreateObject("MSXML2.ServerXMLHTTP")    
    					http_obj.Open "GET", url , false 
    					http_obj.send()
    					strResponse = http_obj.ResponseText
    					set http_obj=nothing 
    					Response.Write strResponse
    			Else
    				Response.Write("Error: " & page & " not found")
    			End If
    	
    		set fs=nothing
    	End If
    %>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •