Results 1 to 7 of 7
  1. #1
    New Lounger
    Join Date
    Feb 2010
    Location
    Nottingham
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I have revamped my website and want to use an Include file to change <TITLE>Your Title goes here</TITLE> for example to <TITLE>Home</TITLE> or <TITLE>Links</TITLE> based on the name of the file. I cannot find a piece of code to help do this. Any suggestions?

    My site has dozens of pages and i have already set up Include files for Header, Navigation bar etc. but don't want to leave them all titled "Your Title goes here".

    Many thanks in anticipation of your help.

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts
    Quote Originally Posted by moonlander View Post
    I have revamped my website and want to use an Include file to change <TITLE>Your Title goes here</TITLE> for example to <TITLE>Home</TITLE> or <TITLE>Links</TITLE> based on the name of the file. I cannot find a piece of code to help do this.
    The usual technologies for this are "server side includes" and scripting language such as PHP, ASP, JSP, Perl, etc. The trick to getting the web server to read and process pages so that includes work is the file extension, e.g., .shtml for server side includes on some servers.

    The first question is, are you already using a scripting language and, if not, which web server do you use (e.g., Microsoft's IIS or Apache on Linux)?

  3. #3
    New Lounger
    Join Date
    Feb 2010
    Location
    Nottingham
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by jscher2000 View Post
    The usual technologies for this are "server side includes" and scripting language such as PHP, ASP, JSP, Perl, etc. The trick to getting the web server to read and process pages so that includes work is the file extension, e.g., .shtml for server side includes on some servers.

    The first question is, are you already using a scripting language and, if not, which web server do you use (e.g., Microsoft's IIS or Apache on Linux)?
    Hi,
    I am using Microsoft .asp which I test on 7Host.com.

    I am going to have a go at learning php but have not got there yet.

  4. #4
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts
    Quote Originally Posted by moonlander View Post
    I am using Microsoft .asp which I test on 7Host.com.
    ASP is great. PHP is good, too, but it's so much more demanding, always wanting perfect punctuation.

    This article is 11 years old, but Classic ASP hasn't changed that much so it probably will work in this case: 4GuysFromRolla.com - The low-down on #includes. (Despite the strange name, this is an excellent site for Classic ASP articles.)

    == Edit ==

    Here's an example of some code I use to include a header table in a page. I set a variable for the specific title just before the include.

    Code:
    <body>
    <%
    Dim strRptName
    strRptName = "Client Invoice Aging and Trust Balance"
    %>
    The included file starts off:

    Code:
    <%
    ' This should be included just below the body tag of the page to generate the visible header
    %>
    <table width="100%" cellspacing="0" cellpadding="0" id="pghead">
      <tr>
        <td align="left" class="vbig"><%=strRptName%></td>
        <td align="right"><span class="NoPrintSpan">Home
          Feedback</span></td>
      </tr>
    </table>
    Is that similar to what you want?

  5. #5
    New Lounger
    Join Date
    Feb 2010
    Location
    Nottingham
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Jscher2000,
    I am not sure. I want the content of <Title></Title> to pick up from the file name of the .asp page it is opening, eg. Links.asp or Map.asp or whatever to give <Title>Links</Title> or <Title>Map</Title> etc. Is this what your code will do?

  6. #6
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts
    Quote Originally Posted by moonlander View Post
    I want the content of <Title></Title> to pick up from the file name of the .asp page it is opening, eg. Links.asp or Map.asp or whatever to give <Title>Links</Title> or <Title>Map</Title> etc. Is this what your code will do?
    No, but I think I know how you can get that information. Check out <%=Request.ServerVariables("SCRIPT_NAME")%> which should contain the name of the page; you will need to do a little string parsing (e.g., using InStrRev) to trim off the rest of the path and then if the capitalization is not right, fix that up.

    Any luck?

    == Edit ==

    If you are new to VB, VBA, and VBScript, then the above reference to InStrRev probably is too cryptic, but if you search around, you should be able to find some good examples.

  7. #7
    New Lounger
    Join Date
    Feb 2010
    Location
    Nottingham
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Many thanks. I'll take a look.

Posting Permissions

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