15 Mar, 2008 in Uncategorized by Ginger

NiceEdit customizations in WordPress

If you’re not a sister GeekGirl, you’re probably not going to be interested in this post, so I’ll spare you by placing the code hacks under the cut of this post. If, however, you are using WordPress blogging software, and you’re interested in having a fully customizable WYSIWYG rich text editor for your visitors to use when they leave comments, please do

Welcome, fellow geek! *much luv* I suppose I should start from the beginning for those of you that haven’t heard of NicEdit, so I’ll quote directly from their site:

NicEdit is a Javascript/AJAX inline content editor to allow easy editing of web site content on the fly in the browser. It integrates into any site in seconds to make any element/div editable or convert standard textareas to rich text editing.

Using this cool little java script on your WordPress blog is really easy! All you have to do is add a couple of lines of script code to your theme’s header.php page, and you’re done. I’ve chosen to use the script as it’s served off the NicEdit servers because I won’t have to update it as they make changes that way… but they do offer the script elements in a zip file, if you choose to host the script on your own servers. ;)

The only problem with the really simple script code they give you is that, as a default, it will effect every textarea form element on your blog. This means that all your comment input areas, as well as any contact form textareas will be converted to the NicEdit WYSIWYG editor. This is where I ran into a bit of trouble.

Using the script code in it’s default format, completely destroyed the cforms II plugin output on my contact page. Luckily, they do offer some code snippet changes on the NicEdit site, in the event that you need to customize your editor use like I did.

Admittedly, I am a completely self taught web geekgirl, so it took some trial and error, coffee, and a few smokes to figure out how to exclude the contact form from the NicEdit effect. Then of course, once I saw all the display options for the WYSIWYG editor, I had to change that too. LOL

I’ve outlined the necessary steps to customizing your usage of the NicEdit script below. I’m hoping to save a coding newbie the trouble of puzzling this out for themselves, the way I had to. Hope this helps!

Adding the NicEdit java script code to your WordPress blog so that it only effects your comment textarea

The code supplied by NicEdit defaults to effecting every textarea on the page that you place the script on. Since your comment textareas in WordPress can be found on all your single post pages (single.php), and your pages (page.php)… it’s easiest just to add the javascript code to your header.php file so that it effects all your comment forms site wide.

The problem with using the header.php file is that the NicEdit JS would then also effect any textarea on your blog. If you use a contact form, this is an issue… so you need to tell the JS to only apply the NicEdit effect to your comments textareas. To do this, use this code (remember that this example uses the JS served off the NicEdit server):

View the code here
note: using the code tag in a post when you have NicEdit running isn’t an option

Place the code above into your header.php file… anywhere will do, but out of habit, I placed mine before the /head tag. Upload your edited header.php file to your theme’s directory and you will notice the new NicEdit editor on all your comment textareas… but any other textarea on your site will be uneffected! Yay!

Now, if you’re like me and must have all the toys with all the possible options available, you’ll want to offer your visitors a “fully loaded” text editor! LOL To do that, use this code:

View the code here
note: using the code tag in a post when you have NicEdit running isn’t an option

There you have it… all in an effort to encourage your visitors to comment on your blog! LOL Try out my customized version of the NicEdit WYSIWYG editor by commenting on this post… especially if you found it helpful! Thanks! ;)

ETA: After all this hacking, I just found a WordPress plugin that essentially does the same thing (applying the NicEdit script to ONLY your comment textareas). I have no idea if it’s updated to work with WordPress version 2.3.3, but you can check it out here. It looks like he’s customized the edit buttons that are displayed too. If you try the plugin, let me know how it works for ya (comment please LOL).

Tags: , , , , , , , , , , ,

11 Responses so far | Have Your Say!

  1. David - Gravatar

    David  |  March 27th, 2008 at 1:09 am #

    Just tried out the Nicedit plugin. When I try to comment, it keeps giving me “Error: please type a comment”.

  2. Ginger - Gravatar

    Ginger  |  March 27th, 2008 at 11:43 am #

    Hmm… the only thing I can think of is that you may not have your javascript enabled on your browser? Either that, or one of your plugins is competing with it, and winning. I had to disable NiceEdit when I installed the “clickable smilies” plugin for the same reason.

    Good luck with it David

    Ginger’s last blog post… New art using the Wacom tablet and pen. Share the commentLuv and visit their blog!

  3. Tao - Gravatar

    Tao  |  April 10th, 2008 at 7:59 am #

    Thanks WenchGinger!

    You saved me alot of messing about!

    Tao’s last blog post… Test post. Share the commentLuv and visit their blog!

  4. Sue - Gravatar

    Sue  |  April 10th, 2008 at 10:11 pm #

    Hi Ginger,
    I need to use this for people submitting posts as well using the TDO Mini form. Can you tell me what the template tag would be for that?

    thanks in advance!
    Sue

  5. Ginger - Gravatar

    Ginger  |  April 11th, 2008 at 2:18 am #

    Tao: you’re very welcome!

    Sue: What version of WP are you using? The rich text editor (aka “visual editor”) should have most (if not all) of the same abilities, do you have that turned on for the posters of your blog? You can do so in their profile pages. I’m not sure what the “TDO Mini form” is, let me know?

    Ginger’s last blog post… Vampire Fashion Contest. Share the commentLuv and visit their blog!

  6. kalapacengkir - Gravatar

    kalapacengkir  |  April 14th, 2008 at 10:41 pm #

    nicedit for wordpress
    a plugin that will replaces the default Wordpress editor with Nicedit

    hi guys..

    may this help..
    frankly, only a simple hack, just to show a “how to”. It’s you who would develop a better one. let me know when it’s done :D

    have fun.

    here it is:
    http://www.4shared.com/file/44141246/29140ec3/nicedit_for_wordpress.html

  7. Ginger - Gravatar

    Ginger  |  April 15th, 2008 at 5:29 am #

    Thanks for the info, kalapacengkir.

    (I haven’t downloaded the above file from kalapacengkir, as I don’t think it’s a good idea to alter something as embedded in the core WordPress code as their editor, but thought some of you may be interested enough to try it.)

    Ginger’s last blog post… Free fantasy art wallpapers!. Share the commentLuv and visit their blog!

  8. Jason - Gravatar

    Jason  |  May 8th, 2008 at 10:51 pm #

    Awesome! thanks for the information. That is a nice addition to a wordpress blog. I like how nice they make it. One solution to keep it from affecting your whole site (if you site is structured this way) is to only include it in the head section of your posts page. I do not have commenting on my pages nor on the index page (which is a static page). If I decide to use this, I will simply create a second header for my pages and one for my posts. The one with my posts will have the javascript for the editor. I will keep my contact forms on pages. Thanks for the information!

    Jason’s last blog post… Give Browser Specific CSS Files With PHP. Share the commentLuv and visit their blog!

  9. BloggerOfTheWeb - Gravatar

    BloggerOfTheWeb  |  June 14th, 2008 at 1:25 am #

    This WordPress Plugin is cool. But I am using WordPress 2.5.1 here. Anybody tried with any issue? I think it is good to find out first before doing the implemetation. Please advise.

    BloggerOfTheWeb’s last blog post… SEO & Blogging: A Smarter Way To Comment Effectively In DoFollow Blogs. Share the commentLuv and visit their blog!

  10. brajesh - Gravatar

    brajesh  |  July 13th, 2008 at 2:56 pm #

    hi
    Nice post.I just released a plugin named Wp NicEdit,with this plugin you don’t have to do anything manually.just upload the plugin and activate.It will turn your comment text area into visual editor(using NicEdit).
    You may check it here
    http://geekytalks.com/2008/07/wp-nicedit-a-wysiwyg-comment-editor-for-wordpress.html

    Regards
    Brajesh

  11. Ginger - Gravatar

    Ginger  |  July 13th, 2008 at 3:40 pm #

    Thanks for the heads up, brajesh!

    Gingers last blog post..New games arrive while I play Puzzle Hero

Leave a Feedback

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>