Character limits and issues

6 posts by 3 authors in: Forums > CMS Builder
Last Post: March 17, 2009   (RSS)

By design9 - March 2, 2009

I have set up a page for our web editors to edit a daily post and I set the character limit in the WYSIWYG editor to 660 characters. We need this because we have a small area and need to confine how much text is entered.

This is the problem: both web editors have stated that everytime they go to post that the system tells them they have went over the limit by 2000 to 4000 characters which is not the case. For some reason, their computer is remembering old data and I have also advised the editors to clear out their cache in their browser. One said that this doesn't fix it. I know one user is using the newest Firefox browser. Also, these web editors are not very web technical based and have older computers.

When I have tested this on different computers and browsers, I don't experience any such problem. Do you have any idea of why they both would experience this issue and any way to fix this?

April

Re: [ross] Character limits and issues

By design9 - March 2, 2009

Hi Ross!
Thanks for a quick reply!

The only issue is that I need to use the WYSIWYG editor because our web editors need to be able to easily add links in their text as they do not have any basic html knowledge to write links on their own.

Is there any way around it using the WYSIWYG or do you have any other solutions?

Thanks!
April

Re: [apdance9] Character limits and issues

By Dave - March 2, 2009

Hi April,

We could update the code to have it apply to the text content of the wysiwyg only (ignoring html tags). That would probably make more sense. Would that work for you?
Dave Edis - Senior Developer
interactivetools.com

Re: [apdance9] Character limits and issues

By ross - March 2, 2009

Hi April

If the way Dave described is the way you want to go, I have a fix for you :). It will be included in the next version of CMS Builder but for now, you can open up this file:

/lib/menus/default/save.php

and find this block of code:

if ($value != '' && @$fieldSchema['minLength'] && $length < $fieldSchema['minLength']) {
$errors .= sprintf(__('\'%1$s\' must be at least %2$s characters! (currently %3$s characters)'), $labelOrName, $fieldSchema['minLength'], $length) . "\n";
}
if ($value != '' && @$fieldSchema['maxLength'] && $length > $fieldSchema['maxLength']) {
$errors .= sprintf(__('\'%1$s\' cannot be longer than %2$s characters! (currently %3$s characters)'), $labelOrName, $fieldSchema['maxLength'], $length) . "\n";
}


It will start on line 106. Replace that while block with this whole block:

// check min/max length of content
$textLength = ($fieldSchema['type'] == 'wysiwyg') ? strlen(strip_tags($value)) : strlen($value);
if ($value != '' && @$fieldSchema['minLength'] && $textLength < $fieldSchema['minLength']) {
$errors .= sprintf(__('\'%1$s\' must be at least %2$s characters! (currently %3$s characters)'), $labelOrName, $fieldSchema['minLength'], $textLength) . "\n";
}
if ($value != '' && @$fieldSchema['maxLength'] && $textLength > $fieldSchema['maxLength']) {
$errors .= sprintf(__('\'%1$s\' cannot be longer than %2$s characters! (currently %3$s characters)'), $labelOrName, $fieldSchema['maxLength'], $textLength) . "\n";
}


Give it a shot and let me know how you make out :).
-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/

Re: [ross] Character limits and issues

By design9 - March 17, 2009

Thanks for your help! That worked like a charm!

April