Fog Creek Software
Discussion Board




Knowledge Base
Documentation
Terry's Tips
Darren's Tips

how do create text file with all bodies

A client wishes to have all of the articles in his site published as text (or MSWord) files. 

Should I make a new copy of the cty file and change the template to produce txt file?

Should I create html files containing only the body text, and write a note describing how to open these in word?

Any other ideas?

thanks all

joel goldstick
Thursday, January 22, 2004

I read a bit in the help file.  I created a second template family called Text.  I edited my template in that family to only the following:

{$.headline$}
{$.body$}
++++++++++++++++++++++

I changed the extension to .txt

But not I get <name>.txt files with embedded html markup.  Is there a way to strip away the markup?

joel goldstick
Thursday, January 22, 2004

Try using ReplaceEm from http://www.boolean.ca/replace/ to run a post-processing step on the directory that contains your .txt files. Set it up to remove everything between angle brackets.

ReplaceEm is surprisingly helpful in making CityDesk do stuff it was never intended to do ...

David Walker
Thursday, January 22, 2004

I coded some html files (contained HTML tables), but gave those files a .xls extension. Excel opened the files without complaint and also put bold etc. where I wanted it.

If you try giving .doc extension to your template/files you might get the same thing??

Dan
Saturday, January 24, 2004

I wanted to let you all know how I ended up solving this problem. 

Goal:  produce MS Word documents of the content of a website.

Solution:  I broke down and read the help file section which discussed template families.  I set up a template family called Text.  This makes CD publish my complete site to two subdirectories -- HTML, and Text.  The same set of templates that I had for my HTML site are replicated for the Text template family.  I edited them to include only the Body content, since I didn't want any navigation in the Word docs.  Then, I added this to the top of the template:

<%
' Tells the browser to open table using MS-Word
Response.ContentType = "application/msword"
%>

This is ASP code which must go above the DOCTYPE declaration.  (Or maybe just before the end of the head section???)

I also created a new page which contained a foreach loop that gave me links of everything in the /text side of my site.

I published the site to my local machine. 

Clicking on each of the /text article links brings up the page in MSWord format.  Save the document, and you have a Word document for the content of your webpages.  The structural elements (H1, h2, etc.) end up being styles in the Word doc.

One note:  The word doc doesn't read the stylesheet, so it looks plain.  That was fine with me.

Conclusion:  This was easier to do than to explain.  Maybe some of you folks will find this technique useful.

joel goldstick
Monday, January 26, 2004

*  Recent Topics

*  Fog Creek Home