Character limits and issues

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

Re: [apdance9] Character limits and issues

By ross - March 2, 2009

Hi April

Thanks for posting!

What's happening here is the character counter is also counting the HTML that is auto created by your WYSIWYG editor when you start typing. The easiest solution would be to switch that field over to a plain text box.

You wouldn't get the formatting options like bold/italics/etc, but it would mean the character count is accurate.

Let me know what you think :).
-----------------------------------------------------------
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 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