SSI calls This technique will save you allot of time like it has for us. It is easier then using CGI scripts and only takes a minute to set up. Once you have everything set up you will be able to update all your pages at once. You can hold any information you need in one file and place it any where you want on all files, so you could have your main menu HTML code in one file that displays on all pages. That way you just need to edit one file instead of 500 the next time you update :-) Can You Run SSI? The easiest way to check is to post a file that tried to grab something from the server. Copy what is below and paste it into a new document. Save it as an .HTML or you might have to save it as an .SHTML file, then upload it to your server. Then use your browser to look at it. You should see the current day name ( Saturday). If you see the day name, you're good to go. If not, you can try contacting your server people to see if they'll configure the server for you. If it works, read on. You're in for some good tips below. I use SSI for menus, headers, and footers the most, but I'm sure you can come up with several more uses for it. OK, now on with the actual information you need. Before you create any .shtml pages make sure your host supports SSI calls, just ask them and they can set it up if they don't. This tip will take your current menu and make it so you only have to edit one file the next time you make changes to it. First open your home page in your favorite editor and fine the menu code, either text or graphical doesn't matter. Cut the HTML coding for your menu and create a new file called menu.shtml, paste the menu code into that file and save it. Then enter the code below in the place of where your menu used to be in the index.shtml file. Use the code below to have the menu.shtml appear inside your home page. <!--#include file="menu.shtml" --> This is the code that makes plugit/menu.shtml appear imbeded in the index.shtml. You use the virtual if the file you are calling isn't in the same directory as the page calling it. <!--#include virtual="plugit/menu.shtml" --> Then whenever your home page gets accessed the menu will appear, this will only work on the actual server machine, not on your hard drive. So you will need to upload it to test it. More Functions: Getting more into the functions you will learn how to control the output of the Date code below. <!--#command tag1="value1" tag2="value2" --> Each command tag takes on different arguments, most only accept one tag at a time. Here is a breakdown of the commands and their associated tags: config The config directive controls various aspects of the file parsing. There are two valid tags: errmsg controls what message is sent back to the client if an error includes while parsing the document. When an error occurs, it is logged in the server's error log. timefmt gives the server a new format to use when providing dates. This is a string compatible with the strftime library call under most versions of UNIX. sizefmt determines the formatting to be used when displaying the size of a file. Valid choices are bytes, for a formatted byte count (formatted as 1,234,567), or abbrev for an abbreviated version displaying the number of kilobytes or megabytes the file occupies. include include will insert the text of a document into the parsed document. Any included file is subject to the usual access control. This command accepts two tags: virtual gives a virtual path to a document on the server. You must access a normal file this way, you cannot access a CGI script in this fashion. You can, however, access another parsed document. file gives a pathname relative to the current directory. ../ cannot be used in this pathname, nor can absolute paths be used. As above, you can send other parsed documents, but you cannot send CGI scripts. echo prints the value of one of the include variables (defined below). Any dates are printed subject to the currently configured timefmt. The only valid tag to this command is var, whose value is the name of the variable you wish to echo. fsize prints the size of the specified file. Valid tags are the same as with the include command. The resulting format of this command is subject to the sizefmt parameter to the config command. flastmod prints the last modification date of the specified file, subject to the formatting preference given by the timefmt parameter to config. Valid tags are the same as with the include command. exec executes a given shell command or CGI script. It must be activated to be used. Valid tags are: cmd will execute the given string using /bin/sh. All of the variables defined below are defined, and can be used in the command. cgi will execute the given virtual path to a CGI script and include its output. The server does not perform error checking to make sure your script didn't output horrible things like a GIF, so be careful. It will, however, interpret any URL Location: header and translate it into an HTML anchor. SSI Environment Variables A number of variables are made available to parsed documents. In addition to the CGI variable set, the following variables are made available: DOCUMENT_NAME: The current filename. DOCUMENT_URI: The virtual path to this document (such as /docs/tutorials/foo.shtml). QUERY_STRING_UNESCAPED: The unescaped version of any search query the client sent, with all shell-special characters escaped with \. DATE_LOCAL: The current date, local time zone. Subject to the timefmt parameter to the config command. DATE_GMT: Same as DATE_LOCAL but in Greenwich mean time. LAST_MODIFIED: The last modification date of the current document. Subject to timefmt like the others. strftime(3) format-code A single character that specifies the date and time conversion to per- form. The following list describes the conversion code characters: a The short day of the week is output as a string as defined for the current locale (Mon, for example). A The long day of the week is output as defined for the current locale (Monday, for example). b (or h) The short month is output as a string as defined for the current locale (Jan, for example). B The long month is output as a string as defined for the current locale (January, for example). c The date and time is output with the default date and time as defined for the current locale. C The century is output as a decimal number in the range 00 to 99. d The day of the month is output as a number between 01 and 31. D The format is fixed to return %m/%d/%y. (For example, 20 Jun 1990 will return 06/20/90.) e The day of the month is output as a number between 1 and 31 in a 2-digit field with leading space fill. Ec Specifies the locale's alternative appropriate date and time representation. EC Specifies the name of the base year (period) in the locale's alternative representation. Ex Specifies the locale's alternative date representation. EX Specifies the locale's alternative time representation. Ey Specifies the offset from %EC (year only) in the locale's alterna- tive representation. EY Specifies the full alternative year representation. H The hour of the day is output as a number between 00 and 23. h Same as b. I The hour of the day is output as a number between 01 and 12. j The Julian day of the year is output as a number between 001 and 366. m The month of the year is output as a number between 01 and 12. M The minute is output as a number between 00 and 59. n Only a newline character is output. N The locale-dependent Emperor/Era name is output. o The locale-dependent Emperor/Era year is output. Od Specifies the day of the month using the locale's alternative numeric symbols. Oe Specifies the day of the month using the locale's alternative numeric symbols. OH Specifies the hour (24-hour clock) using the locale's alternative numeric symbols. OI Specifies the hour (12-hour clock) using the locale's alternative numeric symbols. Om Specifies the month using the locale's alternative numeric sym- bols. OM Specifies the minutes using the locale's alternative numeric sym- bols. OS Specifies the seconds using the locale's alternative numeric sym- bols. Ou Specifies the weekday as a number in the locale's alternative representation (Monday=1). OU Specifies the week number of the year (Sunday as the first day of the week) using the locale's alternative numeric symbols. OV Specifies the week number of the year (Monday as the first day of the week, rules corresponding to %V), using the locale's alternative numeric symbols. Ow Specifies the week day as a number in the locale's alternative representation (Sunday = 0). OW Specifies the week number of the year (Monday as the first day of the week) using the locale's alternative numeric symbols. Oy Specifies the year (offset from %C) in alternative representation. p The AM or PM indicator is output as a string specified for the current locale. r The time in AM/PM notation is output, according to British/US con- ventions (%I:%M:%S [AM|PM]). R The time in hours (24-hour clock) and minutes (%H:%M). S The second is output as a number between 00 and 61. t Only a tab character is output. T The time is output as %H:%M:%S. u Specifies the weekday as a decimal number [1,7], with 1 represent- ing Monday. U The week number of the year (Sunday as the first day of the week). Output format is a decimal number between 0 and 53. V The week number of the year (Monday as the first day of the week). Output format is a decimal number between 1 and 53. If the week containing January 1 has four or more days in the new year, then it is considered week 1; otherwise, it is week 53 or the previous year, and the next week is week 1. w The day of the week is output as a number between 0 (Sunday) and 6. W The week number of the year (Monday as the first day of the week). Output format is a decimal number between 0 and 53. x The short date is output in the format specified for the current locale. X The time is output in the format specified for the current locale. y The year is output as a number (without the century) between 00 and 99. Y The year is output as a number (with the century) between 0000 and 9999. Z The (standard time or daylight saving time) time zone name or abbreviation is output as a string from the environment variable TZ (CDT, for example). If no time zone information exists, no characters are output. % The % (percent) character is output. Those are the codes you can use to display the time formats just how you want them. For the date below I used this code: Saturday, July 4, 2009 |
Join Today - Sign-In -
Affiliate Program - About Us - Privacy Statement - Newest Images - Site Map - RSS - Blog
GraphicsFactory.com is Celebrating 11 Years Online!
Copyright © 1997-2008 GraphicsFactory.com. All Rights Reserved.