Forum Moderators: phranque

Message Too Old, No Replies

SSI - How can I use a variable + string in a file include?

         

DavidJohnny

2:12 pm on Jul 26, 2005 (gmt 0)

10+ Year Member



Does anybody know how to use a variable value as part of a filename in a file or virtual include? I want to be able to include a file based on a variable name, something like this:

<!--#include virtual="variablename.html"-->

So if the value of my variable was "xyz" the file included would be "xyz.html".

Thanks in advance!

jdMorgan

8:59 pm on Jul 26, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I dunno, never tried it, but maybe something like:

<!--#include virtual="${variablename}.html" -->

Note space before "-->", too.

Ref: [httpd.apache.org...]

Jim

Span

9:35 pm on Jul 26, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I used XSSI a lot until a year ago when I needed MySQL, so had to start learning PHP. But I have some bookmarks left.

An (X)SSI tutorial:
[uic.edu ]

Not sure if I'm allowed to post this link, page about using one variable:
[ordersomewherechaos.com ]

coopster

10:14 pm on Jul 26, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Where is the variable coming from? Is it an Apache variable [httpd.apache.org]? Or a scripted variable (Perl, PHP, etc.)?

DavidJohnny

3:44 am on Jul 27, 2005 (gmt 0)

10+ Year Member



Thanks, All. It looks like it's as simple as JD's suggestion, like this:

<!--#include virtual="${variablename}.html" -->

I must have gone through 50 SSI tutorial sites without seeing this, but the UIC site above had it.

This is for a today in history type page. I will get the local date, and use the variable in the file name, like this:

<!--#config timefmt="%b-%d" -->
<!--#set var="today" value="date_local" -->
<!--#include virtual="today-in-history/$today.html" -->

Can't wait to try it. Thanks!