Limit WYSIWYG options per section

20 posts by 7 authors in: Forums > CMS Builder
Last Post: June 15, 2012   (RSS)

By sublmnl - November 2, 2009

Thanks, I'll try it out and see how it goes.

Re: [sublmnl] Limit WYSIWYG options per section

By sublmnl - December 3, 2009 - edited: December 3, 2009

okay so we got an item in an older project that just cries out for this.
so now I get to play...

Dave I'm a little confused, are you saying do this:

// this is called once for each wysiwyg editor on the page
function initWysiwyg($fieldname, $uploadBrowserCallback) {
global $SETTINGS;
$includeDomainsInLinks = $SETTINGS['wysiwyg']['includeDomainInLinks'] ? "remove_script_host : false," : "";
$programUrl = pathinfo($_SERVER['SCRIPT_NAME'], PATHINFO_DIRNAME);
$programUrl = preg_replace("/ /", "%20", $programUrl);

// call custom wysiwyg functions named: initWysiwyg_sectionName_fieldName() or initWysiwyg_sectionName()
if (__FUNCTION__ == 'initWysiwyg_TableName_FieldName') {
$fieldnameWithoutPrefix = preg_replace("/^field_/", '', $fieldname);
$fieldSpecificFunction = "initWysiwyg_{$GLOBALS['tableName']}_$fieldnameWithoutPrefix";
$sectionSpecificFunction = "initWysiwyg_{$GLOBALS['tableName']}";

if (function_exists($fieldSpecificFunction)) { return call_user_func($fieldSpecificFunction, $fieldname, $uploadBrowserCallback); }
if (function_exists($sectionSpecificFunction)) { return call_user_func($sectionSpecificFunction, $fieldname, $uploadBrowserCallback); }
}

// display field
print <<<__HTML__


obviously change the names to what I need it to...

I'm thinking there is a step two somewhere I'm missing to tell what in the section I want and don't want.

You can how specify specify the wysiwyg looks on a per section or per field basis.


hmnnn where?

Re: [sublmnl] Limit WYSIWYG options per section

By Damon - December 3, 2009

Hi,

Try using the attached wysiwyg_custom.txt file.

The first function is the default wysiwyg editor, the second function is the custom editor, with only 1 row of buttons for example.

Search and find this "initWysiwyg_services_content".

Replace "services" with your section name and "content" with your wysiwyg field you want to customize.

Save it as wysiwyg_custom.php and uploaded it to the /lib/ folder.

To have more custom wysiwyg editors, copy and pastw the 2nd function and change the section and field names.

Add/remove buttons as needed.

I hope this helps. [:)]
Cheers,
Damon Edis - interactivetools.com

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

wysiwyg_custom.txt 9K

Re: [Damon] Limit WYSIWYG options per section

By sublmnl - March 8, 2010 - edited: March 8, 2010

well the previous project we haven't touched it and the client is still happy but I really want to do this now.

I copied and saved the code as wysiwyg_custom.php and put it in: /cmsAdmin/lib/

Well it works which is great!!! (thank you IT team)
But do I need to declare each section's limitations with their own entry on the custom file.... what if I only want limitations on a few of them?
Looks like the other sections are carrying my changes now....
Attachments:

wyswiyg_custom.txt 9K

Re: [sublmnl] Limit WYSIWYG options per section

By Chris - March 9, 2010

Hi sublmnl,

The code in "function initWysiwyg" will run for sections and fields you haven't defined a special "override" function for.

If you want to use the same code for several "override" functions, you can do something like this to have them share your custom code:

// override for table "events", field "content"
function initWysiwyg_events_content($fieldname, $uploadBrowserCallback) { my_initWysiwyg($fieldname, $uploadBrowserCallback); }
// override for all wysiwyg fields in the "jobs" section
function initWysiwyg_jobs($fieldname, $uploadBrowserCallback) { my_initWysiwyg($fieldname, $uploadBrowserCallback); }

function my_initWysiwyg($fieldname, $uploadBrowserCallback) {
// CUSTOM CODE HERE...
}


I hope this helps. Please let me know if you have any questions.
All the best,
Chris

Re: [chris] Limit WYSIWYG options per section

By sublmnl - March 9, 2010 - edited: April 26, 2010

aaaah.
[crazy]

Thats it.
I read that wrong. I thought there were two entries as examples.
The first entry is the standard non-customized and the second almost identical entry is where you want to make different restrictions/allowances.

Got it!
works. Thanks a lot.

Should make that standard[;)]

Also finally got a closer look at Chris' code.
That is exactly what I needed instead of loading 60 lines over and over... you create a function that gets called that has all the same stuff in it for each section.
nice! Thanks

Re: [sublmnl] Limit WYSIWYG options per section

By sublmnl - June 12, 2012

Hi guys, is there an update to this?
The custom wysiwyg tinyMCE code looks different in the later version of CMSB.

Re: [Jason] Limit WYSIWYG options per section

By sublmnl - June 13, 2012

Well we've been using what Chris wrote (post 15) for few years now and the code in the file has changed in the latest update. I'd like a refresh on how to modify this.

see attached custom wysiwyg php file from version 2.14
Attachments:

wysiwyg_custom_001.php 6K

Re: [sublmnl] Limit WYSIWYG options per section

By robin - June 15, 2012

Hey, I took a look into the problem. For section/field custom wysiwyg functions, everything still behaves the same way.
You probably just need to update your custom code to match the new wysiwyg setup. I'd just copy and paste and make the necessary changes.

Hope that helps,
Robin
Robin
Programmer
interactivetools.com