Forum Moderators: phranque
<!--#set var="reqfile" value="$DOCUMENT_NAME" -->
<!--#if expr="$reqfile = exbkeywds.html" -->
<!--#include virtual="exbkeywds.txt"-->
<!--#elif expr="$reqfile = duh.html" -->
<!--#include virtual="duhkeywds.txt"-->
<!--#elif expr="$reqfile = exckeywds.html" -->
<!--#include virtual="exckeywds.txt"-->
<!--#elif expr="$reqfile = exdkeywds.html" -->
<!--#include virtual="exdkeywds.txt"-->
<!--#else -->
<!--#echo var="$DOCUMENT_NAME" -->
<!--#endif -->
I think it would be a smaller file if I could change the $DOCUMENT_NAME of "duh.html" to simply "duh" and if I could also then add to "duh" several additions at several points in the page to make it:
duhkeywords (to then include duhkeywords.txt)
duhtitle (to then include duhtitle.txt)
duhcontent1 (to then include duhcontent1.txt)
etc.
If I can get rid of the .html at the end of duh.html, then I can use DOCUMENT_NAME to eventually allow me to call these other files based on the prefix as added to by me rather than have all of these elif lines.
Any pointers on which topics in the apache 1.3 resources I should reread to learn to do this?
What I am wondering is whether there is a way to change a DOCUMENT_NAME such as "duh.html" to "duh" without the ".html".
If so, any suggestions of which apache topics I should focus on would be appreciated.
If not, then also much appreciated would be letting me know that what I wish to do can't be done with apache alone.
[edited by: 4thePegeh at 3:45 pm (utc) on Mar. 21, 2007]
Alternately, you might consider using PHP instead of SSI, since PHP is much more powerful than the old and primitive SSI directives.
Jim
<!--#set var="reqstdurl" value="$DOCUMENT_NAME" -->
<!--#if expr="$reqstdurl=unitest.html" -->
<!--#set var="inclprefix" value="unitest" -->
<!--#elif expr="$reqstdurl=testfixed3.html" -->
<!--#set var="inclprefix" value="testfixed3" -->
<!--#else -->
<!--#set var="inclprefix" value="unknown" -->
<!--#endif -->
I think I can avoid repeating all of the above at every step by doing it only once and then using:
<!--#include virtual="${inclprefix}meta.txt" -->
<!--#include virtual="${inclprefix}content1.txt" -->
<!--#include virtual="${inclprefix}content2.txt" -->
to insert particular files where needed.
Also, to prevent the if elif else endif statement from getting enormous, I could call any of several similar files so the alernatives are divided between them.
Not very elegant I suspect, but the above works when I test it, so I guess the syntax is correct.
Thanks again for taking the time to suggest the rewrite option.
[edited by: 4thePegeh at 6:27 pm (utc) on Mar. 22, 2007]
My reading has, I think, allowed me to understand much of what is happening. I am new to metacharacters.
The additions to the .htaccess file seem to be having the desired effect because on a requested page I can successfully do these:
<!--#include virtual="${inclprefix}meta.txt" --> (when it is outside ofthe conditional statement)
and
<!--#echo var="inclprefix" -->
The example code is returning an error. My host runs Apache 1.3.37 (Unix)
I think I understand most of it, but I have not found clear explanations of:
/^$/
and of:
/^(none)$/
Does the first refer to inclprefix being without content because the two symbols mean the start and end of a line?
Does the second refer to a string automatically generated when?no matching url exists?
I have been looking at articles on metacharacters and conditional expressions but have not found meanings for the two above.
I understand the / to be for legibility and the ( and ) to group things.
I might have accidentally altered the syntax when I cut and pasted it so I will keep relooking at it.
[edited by: 4thePegeh at 5:58 am (utc) on Mar. 24, 2007]
By adding \ before and after the brackets on (none) it seems to work
<!--#if expr="(${inclprefix}!= /^$/ && ${inclprefix}!= /^\(none\)$/)" -->
I think adding the \ escapes the ( and ) or changes them from meta to a literal characters.
Don't know whether adding the \ raises any other issues though.
I guess I will run with it.
Thanks again for the code example. It will make things much simpler.
[edited by: 4thePegeh at 7:29 am (utc) on Mar. 24, 2007]
The "^" and "$" are start and end anchors used in regular expressions. When combined as "^$", they match a blank string only. For more info about regular expressions, which are used in almost all modern scripting languages, see the regex tutorial cited in our forum charter [webmasterworld.com].
Jim
I think that after working with the answers posted to all 10 of the threads I have started over the past 45 days, I am now in a position to implement this project.
Before I do I will head over and pay the subscription fee. The guidance received here at Webmaster World has, by warning me of unwise paths and offering guidance along wiser ones, saved me time worth more than the subsription price.
Thanks again!
[edited by: 4thePegeh at 6:56 am (utc) on Mar. 26, 2007]