SSI: File Returns

By Joe Burns

Use these to jump around or read it all...
[The Echo Command]
[The Flastmod Command]
[The Fsize Command]

This is the third in a series of Server Side Include (SSI) tutorials. This tutorial will not delve into what SSI actually is or how it works, so you may want to read the original first. There you'll find a little script to test your server and information on how to use the Include command to include other documents in your current document. Plus, you'll be much more prepared for this tutorial.


The Echo Command

Really smart HTML Goodies readers will remember this command from the SSI Date and Times tutorial.

In that tutorial we used the echo command in tandem with the "timefmt" argument to return dates and times. Here, I want to show you four more arguments that go along with the echo command.

The first stands apart from the other three so I'll use it to show you the format:

<!--#echo var="DATE_GMT" -->

The DATE_GMT value returns Greenwich Mean Time from the server. That basically stands alone. The next three are used to return information about the current document (the document the command is sitting on).

<!--#echo var="Document_Name" -->
Returns the name of the document.

<!--#echo var="Document_URI" -->
Returns the path to the document plus its name.

<!--#echo var="Last_Modified" -->
Returns when the document was last posted to the server.

Just plop the commands onto the page where you want them. That's easy enough. Moving along...


The Flastmod Command

The flastmod command is created by smooshing together the text "file last modified."

This may sound much the same as the echo var="Last_Modified" above. It is, but with one major difference: The echo command only deals with the document it is sitting on, while the flastmod command will allow you to return data from any file. Here's the format:

<!--#flastmod file="page.html" -->

The argument is "file" and is pointing at the file to describe. If you want to point to a file sitting somewhere other than the current directory, just put in the full path:

<!--#flastmod file="/dog/tree/page.html" -->

The only downfall I've found is trying to attach to a file on another server. No good. The include should be on the same server.


The Fsize Command

Fsize means file size. The command works the same way as the flastmod, allowing you to attach it to any file on the server following this format:

<!--#fsize file="page.html" -->

The command returns the size of the file you point it toward. Try it with both HTML and image files.

That's That

Enjoy the includes. Hope you can find a good use for them.

 

Enjoy!

 

[The Echo Command]
[The Flastmod Command]
[The Fsize Command]


Make a Comment

Loading Comments...

  • Web Development Newsletter Signup

    Invalid email
    You have successfuly registered to our newsletter.
  •  
  •  
  •  
Thanks for your registration, follow us on our social networks to keep up-to-date