August 14th, 2014, 12:10 AM
Opinions on how best to make 'wysiwyg' editor for mysql database
A friend of mine would like me to create a website for him. While the layout for the most part, I believe he's probably going to want to remain fairly static, he wants to be able to change the content himself. Now he's already mentioned wordpress and he's currently managed to sort of figure out wix (for the record, I've never even attempted to see what that's all about). The problem is that I HATE wordpress. HATE. I've already previously attempted to 'revamp' a wordpress site and I wanted to pull my hair out. My biggest issue with it are:
1) Any time I want to add something that isn't already some sort of prepackaged plugin, it's utter hell.
2) Making 'simple' changes to things like even with css etc...require me to have to search through 100 files in 100 folders to make a change and then when it doesn't work, do that extra work to figure out where it is.
3) As a website designer/developer is more or less a part-time thing, I have zero desire to learn wordpress and get sucked in to that world when I can do anything I want without it....
That being said, I want him to be able to update the site with current content....soooooo the only way I think to do this is by having a mysql database that he can update/insert via a php page. Am I crazy to think that this is a good idea? He'd be the only one updating and I'd protect the page etc...so the one thing I'm not sure about is...unless I'm totally blanking on something, the only way to safely format the text that displays on the actual website, is through css on the actual hardcoding on that page. Right? In other words, if I want to make a certain word bold, then either I have to literally have that one word in that one row be in it's own field that I can then apply css too...right? I'm not sure why I've never comes across this issue before but obviously it can be done one way or another.
For instance, on here, I'm writing in a wysiwyg type interface...I have no idea how this whole post gets inserted into a mysql database with the correct formatting...I mean how can I pass / and  or any other special character and I'm not even sure it would work if I did anyway.... so what's a girl to do??
August 14th, 2014, 01:44 AM
The easiest thing to do would just be to setup some CMS for your friend, rather than program something yourself. The only one I have any personal experience with is ModX which was fairly simple to use once I got the hang of it. There are of course others such as Drupal, Joomla, etc
If you decide you want to go the DIY route though then you'd just have to grab a WYSIWYG editor such as TinyMCE and set that up on a page. Such editors will transform a text area into an editor and then save the generated HTML back to the textarea when the form is submitted. Then all you need to do is take that HTML and put it into your database. You would just save the HTML in a single column with the TEXT type and for display pull it out of the DB and echo it out.
Doing the above would allow the use of any HTML, as well as any CSS or JS they wanted to add. If this is only for your friend and you trust/want to allow that then you're fine. If you'd like to restrict that then you need to run the generated HTML through something like HTMLPurifier to remove anything harmful. As an alternative, you could require them to use some intermediate syntax such as Markdown or BBCode, allowing you complete control over what HTML is generated.
Comments on this post
Recycle your old CD's, don't just trash them
If I helped you out, show some love with some reputation, or tip with Bitcoins to 1N645HfYf63UbcvxajLKiSKpYHAq2Zxud
August 14th, 2014, 01:51 PM
just to add to Kicken's post......there is also GetSimple CMS ...which seems to be quite easy to setup and use.
Comments on this post
August 14th, 2014, 06:04 PM
Thanks both of you!!
kicken...it would only be him and I trust him so I wouldn't be worried about that part. Did I mention I also detest joomla and drupal? I've spent so much time in the past trying to learn and understand things like those cms' and at the end of the day, I realize very quickly that there was no need for it (in my situations...). I'm going to give TinyMCE a try and see what happens I'll also implement some sort of purifier etc. Thanks so much for your opinion and time!
Don...I've never heard of that (not surprising of course since I'm not a cms fan) but a quick look seems to indicate it's no where near as obnoxious as any other cms I've come to hear of so even if I don't use it for this specific site, I may use it in the future. Thank you so much for your suggestion!