XSSI Web Designing

Apache also supports XSSI (eXtended Server Side Includes), which provides more advanced command functions (and, consequently, uses code that is a bit more complicated for non-programmer types).

Flow Control Elements
Flow control elements are a set of if/else commands (similar to if statements used in a programming language) that allow authors to create conditional commands. Using flow control elements, authors can make documents display differently based on specific variables (the "test conditions"). For instance, you could publish one version of your page for users accessing it with the Navigator browser and another for Internet Explorer users. The basic flow elements are:

<!--#if expr="test_condition" --><!--#elif expr="test_condition" --><!--#else --><!--#endif -->

The first command contains the if statement that causes the server to test for a condition (e.g., if the browser is Navigator). If it is found to be true, the server prints the text or executes any SSI commands immediately following the if command. If the test condition posed by the if statement is false, the elif statement (which stands for "else if") is tried next. If the elif test condition is true, the server prints or executes whatever follows it.

Otherwise, the server prints orexecutes whatever comes after else, which acts as a catch-all for every other condition that might exist. An if/else statement like this can have as many elifs as you want to add, each of which is tested in turn, and it does not require that you have an else statement at the end -- in which case, if none of the if or elif statements are found to be true, the server does not do anything.

The endif element ends the if element and is required. In the following example, a greeting is customized based on the user's browser:

<!--#if expr=""$HTTP_USER_AGENT" = "Mozilla"" --> Welcome Netscape User!<!--#elif expr=""$HTTP_USER_AGENT" = "Explorer"" --> Welcome Internet Explorer User!<!--#else --> Welcome!<!--#endif -->

As you can see, this is where a little programming knowledge comes in handy for getting the most out of SSI.

Setting Variables
The standard available environment variables were introduced earlier in this chapter. XSSI adds the capability to create your own variables using the set element as follows:

<!--#set var="category" value="help" -->

Your customized variables can then be used as test conditions using the flow control elements listed earlier.



Face Book Twitter Google Plus Instagram Youtube Linkedin Myspace Pinterest Soundcloud Wikipedia

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Web Designing Topics