Web Page Help 1.2
Local Users Web Page Help
- This is the tag in HTML that creates a hyperlink to another Web page.
- There are four general types of links distinguished by the location of the file you are linking to:
-
- Specifying a URL for a file in the same directory:
<a href="filename.html">Text you want user to see</a>
The previous code produces a link that appears as: Text you want user to see - Specifying a URL for a file in a subdirectory:
<a href="subdir/filename.html">Text you want user to see</a> - Specifying a URL elsewhere on the same server: (Note beginning slash)
<a href="/people/activities/index.php">Outdoor Activities</a>
The previous code produces a link that appears as: Outdoor Activities - Specifying a URL for a file on another web server:
<a href="http://www.theregister.co.uk/2002/05/19/ms_in_peruvian_opensource_nightmare/"> M$ in Peruvian open-source nightmare</a>
The previous code produces a link that appears as: M$ in Peruvian open-source nightmare from The Register.
Other uses of the <a>...</a> tag
- Creation of an email link:
Please <a href="mailto:jarek@math.montana.edu_NOSPAM">email me</a> with your math questions.
The previous code produces a link that appears as: Please email me with your math questions.- The a href tag is also used to link to postscript and pdf files:
PDF version of <a href="/~griff/courses/m240/Review/laplace.pdf">Laplace Transforms</a>
The previous code produces a link that appears as: PDF version of Laplace Transforms - The NAME attribute is used to specify links within a
page.
The links look like: <a href="#bottom">Bottom of the page</a>
The previous code produces a link that appears as: Bottom of the page
You must specify where you want the browser to land with either an id attribute/value pair ( id="bottom") or a NAME anchor ( <a name="bottom"> ).
OR another use: <a href="web_2.php#top">Return to Top of the page</a>
The previous code produces a link that appears as: Return to Top of the page
Note, unlike other attributes, NAME is case-sensitive. - The Target attribute is mostly annoying. but occasionally there is a use like:
<a href="/local/help/images/isaac.jpg" TARGET="NewWindow">Isaac</a> at a recent conference
The previous code produces a link that appears as: Isaac at a recent conference
- Specifying a URL for a file in the same directory:
Server Side Includes (SSI) provide a simple way to embed dynamic content into a web page. The main advantage of SSI over other embedding techniques is the simplicity of learning and using SSI.
A partial list of what is possible using SSI:- Display information, such as filename, file modification time, etc.
- Include the contents of files.
- Utilize and display variables.
- Use simple conditional statements.
- Execute programs or commands.
SSI provide a simple means for simple tasks, and is not intended for complicated programming tasks. Once the directive is processed (and no errors occur) the appropriate text is added to the web page and NO trace of the SSI code remains.
Requirements
- SSI must be 'allowed' in the directory. This is setup in the apache configuration file.
- You must tell the server to parse the document for SSI. Also, setup in the apache
configuration file.
This is most easily done by using the extension .shtml.
Our server has the XBitHack turned off. - Exact syntax followed - see below
SSI Tutorial
HTML uses the names <tag attribute="argument"> whereas
SSI uses <!--#directive argument="value"--> .
No spaces are allowed between the opening delimiter <!-- and the
start of the command. Similarly, between the end of the command and -->, no spaces are
allowed. And yes, this should look a lot like an HTML comment.
The result should look like this:
<!--#configfile="filename.html"-->. Failure to follow this simple rule will result in the
server seeing a <!-- comment --> instead of what you intended.
We wish to include time of last modified information, first we configure the output as:
<!--#config timefmt="%D" -->
This is the time & date command:
<!--#echo var="DATE_LOCAL"--> Today is:
or using: <!--#config timefmt="%d %b %y"--> on
<!--#echo var="LAST_MODIFIED"--> :
Last Modified:
- include -- this directive allows you to include the contents of one file into the current document.
- Same Directory syntax:
<!--#include file="schedule.inc.html"--> - Different Directory syntax:
<!--#include virtual="/some/other/directory/schedule.inc.html"-->
- Same Directory syntax:
- config -- changes some server default responses, also sets
date formats.
The function of the config directive is to "adjust" the server's responses to other directives. It takes two parts, the config directive followed by an instance of the directive. Both must reside inside the same HTML page. - echo -- The echo directive works only with one argument,
var="variable". However, the variable takes a wide variety of values.
Examples: using:<!--#config timefmt="%c" --> -
<!--#echo var="LAST_MODIFIED"-->Returns:<!--#echo var="DATE_LOCAL"-->Returns:<!--#echo var="DATE_GMT"-->Returns:<!--#echo var="DOCUMENT_NAME"-->Returns:<!--#echo var="DOCUMENT_URI"-->Returns:<!--#echo var="SERVER_NAME"-->Returns:<!--#echo var="SERVER_SOFTWARE"-->Returns:<!--#echo var="HTTP_USER_AGENT"-->Returns:<!--#echo var="GATEWAY_INTERFACE"-->Returns:<!--#echo var="REMOTE_ADDR"-->Returns:<!--#echo var="REMOTE_HOST"-->Returns:<!--#echo var="REMOTE_USER"-->Returns:
- fsize -- returns the size of the stipulated file. Note, the output can be modified by the config directive.
-
Same Directory syntax:
<!--#fsize file="web_2.php"-->
Returns:
Different Directory syntax:
<!--#fsize virtual="/people/faculty/images/rgriffiths.jpg"-->
Returns: - flastmod -- returns the last modified date and time of the stipulated file -- also modified by the config directive. (This
directive does the same job as the echo directive's var="LAST_MODIFIED" argument and value.
Same Directory syntax:
<!--#flastmod file="web_2.php"-->
Returns:
Different Directory syntax:
<!--#flastmod virtual="/people/faculty/images/rgriffiths.jpg"-->
Returns: - set directive allows for the creation of variables.
syntax:<!--#set var="variable_name" value="variable_value"-->
An example; on some document, say: page_1.shtml:<!--#set var="local_css" value="/~griff/include/really_silly.css"--> <!--#include virtual="/~griff/include/header.inc.shtml"-->
Then in the file header.inc.shtml we have:<!--#if expr="$local_css"--> <link rel="stylesheet" href="<!--#echo var='page_css'-->" type="text/css" /> <!--#endif -->
- if Simple conditional tests using if/elsif/else/endif.
syntax:<!--#if expr="test_condition_1"--> text rendered if test_condition_1 is true <!--#elif expr="test_condition_2"--> text rendered if test_condition_2 is true <!--#else--> text rendered if test_condition_1 AND test_condition_2 is False <!--#endif-->Examples:<!--#if expr="$DOCUMENT_NAME = /^HW/"--> <link rel="stylesheet" href="/~griff/courses/include/style_assignment.css" type="text/css" /> <!--#else--> <link rel="stylesheet" href="/~griff/courses/include/lec_mis.css" type="text/css" /> <!--#endif--><!--#if expr="$REMOTE_ADDR = /^10.20.30./ || $REMOTE_ADDR = /^10.5./"--> <li><a href="/local/help/">Local Users Help Page</a></li> <!--#endif -->If you see a link on the next line, the 'if' returned true - Local Users Help Page
- exec inserts the execution of a command or CGI script.
syntax:
<!--#exec cmd="/bin/df -h /home"-->
I have this feature turned off - everywhere (in the apache configuration).
Some References
- Apache Tutorial: Introduction to Server Side Includes
- Apache's eXtended Server Side Includes From O'Reilly's ONLamp.
CONFIG TIMEFMT
This table shows all the options which can be used with the config timefmt directive
| option | description | e.g. (hard-coded) |
e.g. (using DATE_LOCAL) |
|---|---|---|---|
| DAY | |||
| %a | abbreviated weekday | Tue | Sun |
| %A | weekday | Tuesday | Sunday |
| %d | day of month (01-31) | 04 | 04 |
| %e | day of month (1-31) | 4 | 4 |
| %w | day of week (0-6, Sunday=0) | 2 | 0 |
| %j | day of year (001 to 366) | 186 | 247 |
| WEEK (week 1 starts on first Sunday of year) | |||
| %U or %W | week number (00 to 53) | 27 | 36 |
| MONTH | |||
| %b | abbreviated month | Jul | Sep |
| %B | full month | July | September |
| %m | month (01 to 12) | 07 | 09 |
| YEAR | |||
| %y | two-digit year | 00 | 05 |
| %Y | year | 2000 | 2005 |
| DATE | |||
| %c | standard date and time | 07/04/00 12:03:21 | Sun Sep 4 17:08:23 2005 |
| %x | standard date | 07/04/00 | 09/04/05 |
| %D | MM/DD/YY date | 07/04/00 | 09/04/05 |
| TIME | |||
| %X | standard time | 12:03:21 | 17:08:23 |
| %r | standard time in local notation | 12:03:21 PM | 05:08:23 PM |
| %T | standard time (24 hr clock) | 12:03:21 | 17:08:23 |
| %H | hour (00 to 23) | 12 | 17 |
| %I | hour (01 to 12) | 12 | 05 |
| %M | minute (00 to 59) | 03 | 08 |
| %S | seconds (00 to 59) | 21 | 23 |
| %p | AM or PM | PM | PM |
| %Z or %z | time zone | GMT Daylight Time | BST |
| LAYOUT | |||
| %n | new line | ||

Our local Tutorials:
| Basic HTML | More Advanced HTML | Return to Top of the page |

