April 17th, 2000, 03:24 PM
I am a total novice, so I apologize if this question is silly.
I am trying to setup a very simple site that will pull text files into an existing template. I am using a simple require
statement, such as:
The first problem is that it does not seem to respect the linefeeds, which are saved in Unix format, and just lists it as one
massive block of text. The second problem is that, obviously, it does not convert symbols such as '&' to '&'.
The reason behind this way of including text into HTML files is so that the lecturers can write articles without having to
deal with HTML and the articles are inserted into the HTML templates with the 'require' statement. Also, the shear
number of text documents that need to be posted would cause a lot of work. I have looked at Project Midguard, but I
tend to shy away from applications with little documentation, even though that would be absolutely ideal.
Any ideas would be really appreciated.
April 17th, 2000, 06:26 PM
Remember that browsers do not display new lines. You'd have to convert the new lines to <br>.
I don't know what you mean by converting & to &. I thought you might have meant
& to &
but that doesn't make sense since you said the text file doesn't contain HTML.
If you want to display a raw text file as HTML you can't do it via require. You'll need to read the file into a variable and do a few things to it such as nl2br() and htmlentities().
April 17th, 2000, 06:44 PM
This bulletin board parsed my HTML. I am talking about HTML entities, such as how to change '&' to '& a m p ;' (spaces between letters since I don't know how to 'escape' HTML).
April 18th, 2000, 08:02 AM
Yes, it did mine as well.
Anyway, I answered your question. htmlentities() is the function you need.
Again, you can't just include() or require() plain text and expect it to display correctly.
April 18th, 2000, 02:04 PM
Thanks ever so much for helping me. I had to change:
which worked exactly right.
Thanks ever so much, I really appreciate you solving my question. Have a great day!