1

For our company intranet, built in PHP and MySQL, I want to add an area where employees can post a short profile of themselves - a couple of paragraphs of text and an image.

What's the best way to convert this kind of plain text input to HTML paragraphs, bulleted lists, links, etc?

Clarification: This content will be displayed in a modal that comes up when you click on the employee's desk on an office map, so a separate wiki or something like that will not work.

4 Answers 4

5

You could implement some very simple wiki-like markup, although "simple" here could vary; consider using something like Markdown to speed up the process.

If you have a not-very-technical audience, you might try simply integrating a "rich text editor" type control onto the page, using something like FCKeditor or TinyMCE, from which you can remove/disable superfluous controls. This provides your users with a more familiar, WYSIWYG-style behaviour.

You can perform some simple whitelisting to restrict the subset of HTML allowed through, in any case.

4

There's a lot to be said for going with the simplest, most intuitive solution. Stackoverflow is a programmer community so people are pretty comfortable with this "Markdown" markup.

But to make it more accessible to the average person who isn't used to bothering with markup of any type, then the most basic solution may be best, so there is absolutely minimum difference between what they see as they type it in, and what it turns out to be on the site. Something along the lines of

$html = "<p>"
  . preg_replace("\n\r?\n", "</p><p>", htmlspecialchars($text))
  . "</p>";

It doesn't have any formatting except that a blank line creates a paragraph break, but depending on the audience, for example if it's a general audience, you may find that this is a better idea. If you give non-technical people a markup syntax for formatting, you may find that it either confuses them and they use it incorrectly and mess something up, needing help, or you may find that they go overboard on the formatting, using as many text styles as they can.

In my role I maintain a MediaWiki wiki as an intranet for this company, and have noticed that in general, while having a wiki is a great idea, its markup language is just not suitable for a general non-technical audience, many of whom prefer to write things up in MS Word, because that is familiar to them, and then upload the Word document to the wiki instead.

The other option is a WYSIWYG editing control within the wiki software. It needs to be good, and as close to "actual" WYSIWYG as possible. It shouldn't be possible to get something looking OK in the preview which is messed up after filtering it server-side, because someone will find a way to do that.

How to allow non-technical people to create links between pages is another matter which you may find to be complicated.

1

While you could use a WYSIWYG editor like FCKEditor, there are many lightweight markup languages you could use. Popular ones include

0

Company wiki pages are good for this, and make it easy for users to format it. A bit of open source software for it too.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.