Custom wysiwyg for some viewers

8 posts by 2 authors in: Forums > CMS Builder
Last Post: August 10, 2011   (RSS)

By avrom - August 6, 2011

Hey guys,

I'm sure somebody has already asked this. I woud like to have a wysiwyg editor that only shows the "spell check" button in the toolbar, for some viewers, but still keep the default wysiwyg fro everything else. Doable?

Cheers
Avrom

Re: [avrom] Custom wysiwyg for some viewers

By Jason - August 8, 2011

Hi Avrom,

Yes, you can do this, but it takes a bit of custom code, so only try this if you're comfortable editing php code. Also, always make a backup of your files first.

Here is what you would do.
First, open up cmsAdmin/lib/wysiywg.php and save it as wysiwyg_custom.php

Next, in wysiwyg_custom.php, you'll see the following code:

// display field
print <<<__HTML__

<script language="javascript" type="text/javascript"><!--
...


Above this we'll add in some custom code like this:



$spellCheckerSections = array('articles', 'news');
$theme_advanced_buttons2 = "theme_advanced_buttons2 : \"forecolor,backcolor,|,link,unlink,anchor,|,blockquote,hr,image,media,table,|,pastetext,pasteword,|,code,|,spellchecker\",";

if (!in_array(@$_REQUEST['menu'], $spellCheckerSections)) {
$theme_advanced_buttons2 = "theme_advanced_buttons2 : \"forecolor,backcolor,|,link,unlink,anchor,|,blockquote,hr,image,media,table,|,pastetext,pasteword,|,code,|\",";
}

// display field
print <<<__HTML__

<script language="javascript" type="text/javascript"><!--


Change $spellCheckerSections to have a list of all of the section where you want the spell checker to appear.

Finally, below all of this, you'll find this piece of code:

// Define buttons: Button codes: http://wiki.moxiecode.com/index.php/TinyMCE:Control_reference
theme_advanced_buttons1 : "formatselect,fontsizeselect,bold,italic,underline,|,justifyleft,justifycenter,justifyright,|,bullist,numlist,|,outdent,indent,|,removeformat,fullscreen",
theme_advanced_buttons2 : "forecolor,backcolor,|,link,unlink,anchor,|,blockquote,hr,image,media,table,|,pastetext,pasteword,|,code,|,spellchecker",
theme_advanced_buttons3 : '',


Change that to this:

// Define buttons: Button codes: http://wiki.moxiecode.com/index.php/TinyMCE:Control_reference
theme_advanced_buttons1 : "formatselect,fontsizeselect,bold,italic,underline,|,justifyleft,justifycenter,justifyright,|,bullist,numlist,|,outdent,indent,|,removeformat,fullscreen",
{$theme_advanced_buttons2}
theme_advanced_buttons3 : '',


That should do it.

Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Custom wysiwyg for some viewers

By avrom - August 8, 2011

Jason, that's perfect. While it would be only the spellcheck field I would show, your example is crystal clear. Thanx a lot man!

Cheers
Avrom

Re: [Jason] Custom wysiwyg for some viewers

By avrom - August 9, 2011

Hi Jason,

Your example works jsut fine. I'd also like to add another line with a "null" statement, since the editor has 2 lines of editor options showing, and I only need one line to display. But not sure the php syntax for that. I know its pretty simple. Thanks in advance :)

theme_advanced_buttons1 : '',

would become?

$theme_advanced_buttons1 = \"CODE\",";

Cheers
Avrom

Re: [avrom] Custom wysiwyg for some viewers

By Jason - August 10, 2011

Hi Avrom,

Do you mean that on certain sections you want to have theme_advanced_buttons1 display and on others you don't?

Let me know.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Custom wysiwyg for some viewers

By avrom - August 10, 2011

Jason, exactly. Just not sure how to call up the two single quotes in PHP to make that happen :)

Cheers and thanx
Avrom

Re: [Jason] Custom wysiwyg for some viewers

By avrom - August 10, 2011

Jason, that's perfect! Thanx for your time and help :)