[ Pobierz całość w formacie PDF ]
.For the web author, this can be a powerful tool for managingsite production and increasing efficiency.The following are just a few examples ofthe ways SSI can be used:" Placing elements that you use over and over again.If you have an elementthat appears on every page of your site, such as a complex navigationalheader, you can place a single SSI command that just sources it in instead.Ifyou make changes to the header, such as changing a URL or a graphic, youonly need to make the change once, and it will be updated automatically onall pages of your site." Place a constantly changing element on your page with a single line.Forexample, if you maintain a homepage that has a message that changes everyday, use a Server Side Include command (and a script on the server) toreplace the message automatically.You never need to touch the source codefor the home page you just let the server do the work.251Web Design in a Nutshell, eMatter EditionCopyright © 2000 O Reilly & Associates, Inc.All rights reserved.How SSI Is Used" Show the date and time the page was last updated." Allow multiple users to submit content for inclusion on a web page withoutgiving them access to the HTML source.For example, staff members couldsend in weekly updates via email.The server could run a script that turns theemail into a text file, which is then inserted into the web page via an SSI com-mand." Serve an appropriate web page based on the browser making the request.You can even serve documents based on the user s domain name.(Note: notall servers can perform conditional functions.This is discussed later in thischapter.)Obviously, these are just a handful of possibilities, but they demonstrate the sortsof tasks Server Side Includes are good for.AdvantagesServer Side Includes offer the following advantages:" It s easy to learn the basic SSI syntax and start implementing simple SSI." Most servers provide support for SSI or can add it quickly (check with yourserver administrator first)." Pages can be dynamically generated, including up-to-the-second informationand content served based on information about the users viewing environ-ment." It isn t browser-dependent like JavaScript, so will work for everyone (as longas it works on your server)." The commands don t display in the browser, so your methods are invisible tothe user." It s less work for the server than processing CGI programs for the same func-tions.DisadvantagesThere are few disadvantages:" Parsing a file and adding information requires slightly more work for theserver than serving a straight HTML document." Enabling Server Side Includes on the server may pose a security risk.Talk toyour server administrator to find out the policy for SSI on your server.Getting the Most Out of SSIThe examples in this chapter illustrate the basic form and function of SSIcommands.On their own, Server Side Includes provides some useful, althoughlimited, tools for dynamic page generation.The real power of Server Side Includescomes in the combination of SSI commands with CGI scripts running on theserver.The CGI programs do the necessary processing before the information isready to be placed in the HTML page.252 Chapter 13 Server Side IncludesWeb Design in a Nutshell, eMatter EditionCopyright © 2000 O Reilly & Associates, Inc.All rights reserved.Adding SSI Commands to a DocumentIf you focus on front-end web design, you can get started right away using theelements and variables listed in this chapter, however, you may need to consult aCGI programmer to design the back-end for more advanced SSI solutions.SSI and the ServerIt should come as no surprise that the function of SSI depends heavily on theconfiguration of the server.This is another instance in which you need to commu-nicate with your system administrator to find out whether your server supports SSIand, if so, which syntax to follow.The instructions in this chapter use SSI commands that work for NCSA HTTPdServer Side Includes, and, specifically, those documented in the Apache server smod_include module
[ Pobierz całość w formacie PDF ]