Click to See Complete Forum and Search --> : loading a certain include file depending on a parameter


gardanni
02-08-2005, 09:21 PM
hi. i've been wrestling with what i thought would be a simple issue. i'm not a programmer, perhaps i just don't get the syntax... i wonder if someone would give me a hand.

1. i have no trouble to take a query string passed in with a URL:
<!--#set var="foo" value="'${QUERY_STRING}.txt"-->

2. i have no trouble to access that variable:
<!--#echo var='foo' -->

3. i simply cannot access that variable when i try to use it in the context of another command:
<!--#include virtual="foo}" -->

I've tried all sorts of variations - foo, $foo, {foo} etc. I am stumped!

phpnovice
02-09-2005, 09:27 AM
To my knowledge, SSI does not lend itself to parameterization. If the following does not work:

<!--#include virtual="${QUERY_STRING}.txt" -->

you'll need a supporting server-side language (e.g., ASP or PHP) to provide the logic and the parameter handling. Do you have access to such a server-side language?

TheBearMay
02-09-2005, 09:59 AM
If it's a limited number of possibilities you may want to consider something like:


<!--#if expr="$QUERY_STRING = 'File1'" -->
<!--#include virtual="File1.txt" -->
<!--#elif expr="$QUERY_STRING = 'File2'" -->
<!--#include virtual="File2.txt" -->
<!--#else -->
<!--#include virtual="File3.txt" -->
<!--#endif -->

phpnovice
02-09-2005, 10:46 AM
Cool. I didn't know SSI had logical constructs. :D
I guess I'm just used to the SSI subset that you get with ASP.

gardanni
02-10-2005, 07:34 AM
Thanks. This worked:

<!--#include virtual="${foo}.txt" -->

I had tried many combinations with the dollar-sign, braces and quotes.... but i hadn't tried this combination!

Programming is difficult, you get completely halted by a tiny piece of syntax. You programmers out there have my admiration!

phpnovice
02-10-2005, 09:17 AM
Yep, I posted that suggestion based on my growing knowledge of PHP syntax. That suggestion was also based on the original #set statement you provided. Sometimes, debugging is connecting one piece of syntax/knowledge from one situation into the syntax of another situation.

Glad it worked for you. ;)