[PHP CMS] Site Text Editor
- vitinho444
- Posts: 2819
- Joined: Mon Mar 21, 2011 4:54 pm
[PHP CMS] Site Text Editor
Hey guys, im trying to improve my websites and upgrade them all to a CMS-like style. Example, i have my admin account and i use it to create news posts and other content.
What i would like to add is a panel like Microsoft Office Word, with the BOLD, Italic, font-size, options that changed the textarea for the content and then put it on the db without any changes and get it again without any changes.
How can i do this?
PS: I already have the insert in db thingy, i just need the editing part
PS2: I'm using a text-area for the content post body.
What i would like to add is a panel like Microsoft Office Word, with the BOLD, Italic, font-size, options that changed the textarea for the content and then put it on the db without any changes and get it again without any changes.
How can i do this?
PS: I already have the insert in db thingy, i just need the editing part
PS2: I'm using a text-area for the content post body.
- Jackolantern
- Posts: 10891
- Joined: Wed Jul 01, 2009 11:00 pm
Re: [PHP CMS] Site Text Editor
It is pretty easy to add stuff like that for as-you-type editing, such as when someone presses the "Bold" button, types some stuff, and then clicks "Bold" again to unbold. You just set up an event on the bold button that has a toggle. When it is toggled on, you add an opening span tag with a class that connects to a bold style in the stylesheet, and then when it is clicked again, it is toggled off and creates the closing span tag.
However, doing it where you can select text and then click the bold button is a bit more complex. I am running through my head on how to do it as simply as possible. My first thought was to just get the selected text, and then do a replace and add the enclosing span tags, but that would not work, because the selected text may appear elsewhere in the text and be altered as well.
However, doing it where you can select text and then click the bold button is a bit more complex. I am running through my head on how to do it as simply as possible. My first thought was to just get the selected text, and then do a replace and add the enclosing span tags, but that would not work, because the selected text may appear elsewhere in the text and be altered as well.
The indelible lord of tl;dr
- vitinho444
- Posts: 2819
- Joined: Mon Mar 21, 2011 4:54 pm
Re: [PHP CMS] Site Text Editor
Hum, would it work if i did something like:
(not 100% correct coding here)
(not 100% correct coding here)
Code: Select all
textarea.innerHTML = textarea.innerHTML + "<b>";
- Jackolantern
- Posts: 10891
- Joined: Wed Jul 01, 2009 11:00 pm
Re: [PHP CMS] Site Text Editor
That would also bold the entire block of text I believe. Doing bolding on the fly while typing isn't that hard (like I mentioned above), but selecting text that is already written and bolding it is a bit tougher. Or at least I think it would be. Text selection is not something I have had a reason to mess with too much in Javascript.
Also, if you wanted to do it CMS style, with permanent changes, you would have to actually have the client send the change and alter it server-side, so future servings of the page reflect the update.
Also, if you wanted to do it CMS style, with permanent changes, you would have to actually have the client send the change and alter it server-side, so future servings of the page reflect the update.
The indelible lord of tl;dr
- vitinho444
- Posts: 2819
- Joined: Mon Mar 21, 2011 4:54 pm
Re: [PHP CMS] Site Text Editor
I've already made that, so we have a textarea with each page of content (it's in my company's website) and other page with textareas and text fields to edit news articles.
I can do the <b> <br> <a href=""></a> while writing down content, but i was kinda looking at the future that i might have a client that prefers a CMS (who wouldn't?).
But thanks for your help
I can do the <b> <br> <a href=""></a> while writing down content, but i was kinda looking at the future that i might have a client that prefers a CMS (who wouldn't?).
But thanks for your help
- Jackolantern
- Posts: 10891
- Joined: Wed Jul 01, 2009 11:00 pm
Re: [PHP CMS] Site Text Editor
So you have already made the back-end part of it? What part are you still missing?
The indelible lord of tl;dr
- vitinho444
- Posts: 2819
- Joined: Mon Mar 21, 2011 4:54 pm
Re: [PHP CMS] Site Text Editor
Well i don't know if you can call it back-end part xDJackolantern wrote:So you have already made the back-end part of it? What part are you still missing?
What i do have is a textarea where i can write everything i want for the news article or other pages content and it will send to the DB and then when someone access that part of the content it just echo the db field
I can write bbcode like i would here <b>Bold<b> but it would be nice to add a full wysiwyg text-editor, but no problem, maybe in the future
- Jackolantern
- Posts: 10891
- Joined: Wed Jul 01, 2009 11:00 pm
Re: [PHP CMS] Site Text Editor
Honestly, for CMS-like features, I would just use something pre-existing and open source, and edit it to fit your needs. There is a staggering number of CMS out there, and many are free and open source. There is no need to reinvent the wheel
The indelible lord of tl;dr
- vitinho444
- Posts: 2819
- Joined: Mon Mar 21, 2011 4:54 pm
Re: [PHP CMS] Site Text Editor
True, but i don't like to see on my websites:
"Powered by Wordpress / Joomla"... That looks strange to me because i can make websites...
"Powered by Wordpress / Joomla"... That looks strange to me because i can make websites...
- Jackolantern
- Posts: 10891
- Joined: Wed Jul 01, 2009 11:00 pm
Re: [PHP CMS] Site Text Editor
Then use one of the hundreds of others that does not require that
The indelible lord of tl;dr