LoginRegisterCommercial SupportContact Us


Development & IT > Handling plain text files

Handling plain text files

posted on 5:03 PM, August 29, 2007
You can place plain text files into your regular web page directory (such as a robots.txt file), and edit and manage the contents of these files using the Website Manager CMS tools.  A few special configurations are needed.

First, you must extend the set of allowed page suffixes to include the page suffix you will be using, such as .txt.  You can do this with a configuration file setting like this:
page.suffix = \.(html?|php|asp|txt)
(This allows you to create web pages with file names ending in .htm, html, .php, .asp, and .txt.)  In the case of a robots.txt file, the file is not really a web page, but from the system's point of view, text files published into the main web page directory all have the same core behaviour, so it is equivalent.  In other cases (for example, the plain text GPL license), it may be fair to treat the plain text file as a perfectly normal page that has a navigation position in menus and everything.

Now you can create the text file in the Website Editor.  Create it like any other page, but give it a filename ending in .txt.  If it is a configuration file like robots.txt, and not really an actual web page, then set it's visibility to "hidden" to keep it out of menus and site maps.  Make sure that it publishes statically and is set to public accessibility, so that a proper text file will be written.

Once the page is set up, you can open it up to edit its content as for a regular page.  The difference is that you will create and edit a page object.  The body object will not be used, and can be deleted.  Important:  when saving the page object, make sure that it's content-type is set to text/plain.

Example (robots.txt):  when editing the page object, enter your plain text content, such as:
User-agent: *
Disallow:
Crawl-delay: 5
In principle you can use CMS tags to perform all of the regular substitutions you could on any other page.

Filed under: programming

Comments

htaccess
by Morgan Burke
posted on 10:59 AM, August 30, 2007
You could also manage an .htaccess file, by adding "htaccess" to the allowed suffix list.
back back