| Home | Register | FAQ | Members List | Search | Today's Posts | Mark Forums Read |
|
|
#1 (permalink) |
|
Senior Member
Join Date: Feb 2003
Location: Canterbury
Posts: 103
|
rtf using php...
Hi I'm using a rtf document to update a news section of a website by the means of php. The code: <? include("whatson.rtf"); ?> This works, my problem is in formatting it - I can use the style sheets on it, that all works but it doesn't keep the original formatting of the rtf document - is there a way of doing this? If you want the example - www.designmedication.co.uk/homepage.php The rtf: www.designmedication.co.uk/whatson.rtf Any help would be much appreciated! Matt |
|
|
|
|
|
#2 (permalink) |
|
trouble free and loverlee
Join Date: Mar 2003
Location: YooKay
Posts: 2,933
|
I"m working with something like that on a current job by way of making it simpler for clients to provide important content. You might find it simpler to switch to plain text (.txt) as it's easier to transfer, store and process. I've used the following set of php instructions to reformat the text as markup PHP Code:
That's just a simplified section of a larger function I've put together that writes and format dynamic modular sections of a gallery site and imports the artists' bios in the scheme. It does a good job of translating the untagged, loosely formatted text of the txt file into properly tagged, well-presented on-screen text. With a little tweaking of the \n (php new line) and \t (php new tab) you can set things up to produce seamless, tab-perfect markup that holds up well in view source. It's great to see it when it works. I'm still new to php and I only sorted the large artist handler function y/day, so I'm still in that 'isn't php great' and feeling just a little proud of myself. In the words of the great Hannibal Smith - I love it when a plan comes together. |
|
|
|
#5 (permalink) |
|
trouble free and loverlee
Join Date: Mar 2003
Location: YooKay
Posts: 2,933
|
If it's certain defined words you wish to emphasise then you can do it using the same method as above. e.g. if you wanted to turn any reference to your name into a simple, clickable email link or simply style it… PHP Code:
PHP Code:
If you want to allow users/clients to input their own data and have styling applied as and when they want then that's when things get a tad more complex - and I bow out, having hit my ceiling. You might want to check out the PHP sections of Hotscripts.com to see what's available. You may well find precisely the facility you're after. http://www.hotscripts.com/PHP/Tips_and_Tutorials/ Last edited by Bill Posters : 07-04-2004 at 05:41. |
|
|
|
#6 (permalink) |
|
I Ain't Losing Any Sleep™
Join Date: Apr 2003
Posts: 5,200
|
Bold Code:
Code:
Code:
That's fuckin' ingenious, if I understand it correctly. It's a Swiss fuckin' watch.
|
|
|
|
#8 (permalink) |
|
trouble free and loverlee
Join Date: Mar 2003
Location: YooKay
Posts: 2,933
|
Aah, seems you've edited it. now it makes sense. Of course, there's that option, but I thought the idea might be to shield users from learning even the most basic hand-code. Also: if you're simply replacing ad-hoc tags with meaningful ones, why not simply get users to add their own <strong>…</strong> and <em>…</em> tags in the first place? |
|
|
|
#9 (permalink) | |
|
I Ain't Losing Any Sleep™
Join Date: Apr 2003
Posts: 5,200
|
Yeah, edited because the board thought I was entering it's own code at first. Quote:
Because you don't really want a user to be able to enter their own (x)html and invalidate yours or worse, fuck up your layout. Use htmlspecialcharacters() to neutralise any xhtml that the user enters but give them some "ad-hoc" tags to preform some basic formating. That's fuckin' ingenious, if I understand it correctly. It's a Swiss fuckin' watch.
|
|
|
|
|
#11 (permalink) |
|
Senior Member
|
I've a similar situation, a client wants to be able to import RTF documents into his intranet, and the nice app will break the document into data fields based on the bulleted lists within the rtf (each item becomes a seperate record within the db). This is for ASP - but are there any simple references on the subject? |
|
|
|
#13 (permalink) | |
|
vague™
Join Date: Mar 2004
Location: Glasgow
Posts: 5,512
|
Quote:
Yeah, a google search for "rtf to html" php. That'll help for a project to be done in asp. Commercial solution: http://www.easybyte.com/products/rtf2html.html couldn't find any decent tutorials but i'm sure there'll be some somewhere.. |
|
|
|
|
#16 (permalink) |
|
trouble free and loverlee
Join Date: Mar 2003
Location: YooKay
Posts: 2,933
|
I tried that and while it is a good, quick way of achieving markup from text, but it didn't produce markup that satisfied my preference for good, clean, well-tabbed end markup. - Fwiw, in PHP 4.05+ nl2br() produces xhtml-compliant <br /> tags. |
|
![]() |