Forum Moderators: phranque
I am trying to use SSI files called from ASP pages to include a menu whose content is based on what page calls the include. Basically, I don't want to have a link in my menu back to the page I am already on. This is for a division's website in a very large work environment. I do not have control of the webserver the pages are hosted on. I have contacted IT and confirmed that SSI includes are active from ASP files but they would not tell me what OS the hosting machines are running nor whether this is run through Apache or IIS.
I call an SSI file with the following relavent code from an ASP page:
<html>
<!--#set var="thisis" value="administration" -->
...
<!--#include file=menu.ssi-->
...
</html>
Here is a snippet of the code from my 'menu.ssi' page:
<div style="float: left;" >
<table style="width: 175px; text-align: left;"><!--#if expr="$thisis = /default/" -->
<tr>
<td>
<img class="menuTable" src="../assets/images/Home.gif" id="" alt="Home" />
</td>
</tr><!--#else -->
<tr>
<td style="padding-left: 5px;" >
<a class="menuHover" href="../default.htm">Home</a>
</td>
</tr><!--#endif -->
<!--#if expr="$thisis = /administration/" -->
<tr>
<td>
<a href="../html/administration.html"><img class="menuTable"
src="../assets/images/Administration.gif" id="Administration" alt="Administration" /></a>
</td>
</tr><!--#else -->
Test<!--#endif -->
...
<p style="text-align: center">
...
Other Menu Content Here
...
</p></table>
</div>
The output is in the following order, items in ()s are actual images displayed as they are formatted:
Test
Other Menu Content Here
(the Home.gif image)
Home
(the Administration.gif image)
Other SSI includes which do not have conditionals in them work normaly when called from this ASP file. I searched the forums here and found some information about a similar problem for php files calling SSI where global variables were turned off. The post suggested this fix which did not work:
<!--#if expr="$_ENV['thisis'] = /default/" -->
instead of
<!--#if expr="$thisis = /default/" -->
I am fairly new to all this so any tips or tricks along with an answer to my prolem are more than welcome.
<!--#set var="thisis" value="administration" -->
The include in your page:
<!--#include file="menu.ssi" -->
And the conditional stuff in your menu.ssi:
<!--#set var="thisis" value="$DOCUMENT_NAME" -->
<!--#if expr="$thisis = /default/" -->
Home code
<!--#elsif expr="$thisis = /administration/" -->
Administration code
<!--#elsif expr="$thisis = /resources/" -->
Links code
<!--#else -->
If nothing
<!--#endif -->
[quote]And the conditional stuff in your menu.ssi:
<!--#set var="thisis" value="$DOCUMENT_NAME" -->[\quote]
Should I not set the variable in my ASP page at all? Will $DOCUMENT_NAME set the variable to the name of the ASP page that calls menu.ssi? I'm new to this like I said and I had no idea it would work that way.
I was trying to keep menu.ssi small by using multiple if/else but they way you're suggesting of having the entire menu code for each condition should get around the issue I'm having. Thanks again for your help.
<% if callingPage = "administration" then %>
<tr><td><a href="../html/administration.html"><img class="menuTable" src="../assets/images/Administration_HTextMenu.gif" id="Administration" alt="Administration" /></a></td></tr>
<% else %>
<tr><td style="padding-left: 5px;" ><a class="menuHover" href="../html/administration.html">Administration</a></td></tr>
<% end If %>
The original problem was that the text in my .ssi file was included into my .asp page but the conditionals were never parsed. By including an .asp page instead of .ssi, the conditionals in the vbscript are parsed correctly.