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 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jun 2002
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Conditional includes (SSI)

    What I need to do would be a trivial exercise if I could use php. Unfortunately php is not available on the server where this problem needs to be solved (and neither is ASP available).

    I need to include a variable in an shtml page and use that variable to determine which other includes are written. This is in the context of a menu system, where if the page is about 'widgets' then additional menu links relating to widgets need to be written into the menu, and similarly if the page is about 'elephants' then different additional menu links need to be written.

    If it's possible, a simple and complete code sample would be extremely helpful.

    Otherwise, I guess I'm stuck with doing the same basic thing client-side using javascript with doc.writes for menu parts - and I'd prefer to avoid that as this particular client believes many surfers run with javascript disabled.

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    NL
    Posts
    421
    Thanks
    0
    Thanked 0 Times in 0 Posts
    <!--#set var="page" value="$DOCUMENT_NAME" -->
    <!--#if expr="$page = /widgets/" -->
    <!--#include virtual="/includes/more_about_widgets.html" -->
    <!--#elif expr="$page = /elephants/" -->
    <!--#include virtual="/includes/more_about_elephants.html" -->
    <!--#elif expr="$page = /coffee/" -->
    <!--#include virtual="/includes/more_about_coffee.html" -->
    <!--#else -->
    <!--#endif -->

    Which reads like this: if the name of the page contains 'widgets', the file more_about_widgets.html will be included; if the page name contains 'elephants', more_about_elephants.html will be included, and so on.
    If the pagename contains none of the expressions <!--#else --> nothing will be included.

  • #3
    New to the CF scene
    Join Date
    Jun 2002
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Excellent. That works flawlessly - on my server (which I know is a *nix server).

    On my client's server (probably a pacbell service) it fails as the directives fails. Checking with BigNoseBird's tutorial, the explanation given is "If you are using Netscape Server or IIS, you will need to check their documentation for the solutions.

    As I don't happen to have IIS (or Netscape server) documentation around .... is there a solution that a mere mortal would understand?


  •  

    Posting Permissions

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