www.webdeveloper.com
Results 1 to 4 of 4

Thread: Dynamic #includes?

  1. #1
    Join Date
    Apr 2003
    Location
    Fredericksburg, VA
    Posts
    91

    Dynamic #includes?

    Hello,

    I run a site in which I use #includes on my asp pages to insert a standard site navigation bar, header and footer on each page. I recently added blogger.com utility to my page for a news and latest features type information. The problem is that the template that I use for blogger is an ASP page with #includes. This works great when you are looking at the blog index. However, the archives get all screwed up because they are archived in year/month directories, and thus the path for the #include gets messed up. Unfortunately I don't believe that you can use full path names for #includes, and you can't make them dynamic. Neither of the following work:
    Code:
    <%
    Dim path
    If isArchivePath Then
       path = "../../.."
    Else
       path = ".."
    End If
    %>
    <!-- #include file="<%=path%>/inc/sidebar.asp" -->
    
    ' OR
    <%
    If isArchivePath Then
    %>
       <!-- #include file="../../../inc/sidebar.asp" -->
    <%
    Else
    %>
       <!-- #include file="../inc/sidebar.asp" -->
    <%
    End If
    %>
    Anyone have any great ideas? I don't believe that I can use two different templates for blogger index page and archived pages.

    Thanks in advance...
    Chris

  2. #2
    Join Date
    Apr 2003
    Location
    Fredericksburg, VA
    Posts
    91
    Nevermind...figured out how to use Server.Execute.

    For referential purposes, do the following:
    Code:
    'The Old Way
    <!-- #include file="../inc/menu.asp" -->
    
    'The New Way (ASP 3.0)
    <%
    Dim menu
    menu = "../inc/menu.asp"
    Server.Execute(menu)
    %>
    If you are using ASP version 2.0, see the 4guys tutorial

  3. #3
    Join Date
    Nov 2003
    Location
    Derby, UK
    Posts
    87
    [Edit: Oops, this was supposed to be a reply to a thread which quoted this thread - sorry..!]

    Cool, I wasn't aware of that one

    Although a quick test shows that page defined variables are not passed through to the executed page, only Server / Application variables.
    For example...
    Code:
    one.asp
    =======
    <%
    nTom=123
    Server.Execute("two.asp")
    %>
    
    two.asp
    =======
    <%=nTom%>
    ...does not display "123".
    Last edited by tomhartland; 10-08-2004 at 03:54 AM.

  4. #4
    Join Date
    Jan 2004
    Location
    Melbourne, Australia
    Posts
    5,298
    The Execute method works slightly different to SSI. SSI simply grabs the code and pastes it into the parent file whilst Execute will actually execute the desired file seperately.

    So both methods are still useful depending on the context of the problem.

    Regards.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles