Is it possible to use this module simply as a warning rather than actually truncating the input? I'd like to use this to have a countdown to 200 characters with the warning "This post will be continued in readmore after 200 characters" and then have the Drupal post settings handle the automatic generation of read more, rather than having the input truncated.

Comments

Coupon Code Swap’s picture

Okay. I think I figured out how to disable the truncating of content. Another benefit to this hack is that Maxlength won't truncate existing content that exceeds the limit, so adjustments can be made rather than losing the truncated content after opening node to edit. It would be nice if this could be added as an option, but for now this is working. For anyone who is interested, here's what I did:

First I adjusted the JavaScript so countdown goes into negative rather than stopping at zero as mentioned here:

http://drupal.org/node/540780

/modules/maxlength/maxlength.js

//if (remainingCnt < 0) {
//  field.val(field.val().substr(0, limit));
//  remainingCnt = 0;
//}

Then I commented out the following:

/modules/maxlength/maxlength.module

/*
    if ($remaining < 0) {
      drupal_set_message(
        t('%body_field_label truncated to %limit characters!',
        array(
          '%body_field_label' => $element['#title'],
          '%limit' => $values['limit'])
        ),
        'error'
      );

      $element['#default_value'] = drupal_substr($element['#default_value'], 0, $values['limit']);
      $remaining = 0;
    }
*/
/*
function maxlength_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
  $fields = array('title', 'body');

  foreach ($fields as $field) {
    $limit = intval(variable_get(MAXLENGTH_NODE_TYPE . $field .'_'. $node->type, ''));
    if ($limit > 0) {
      switch ($op) {
        case 'validate':
          $form = $a3;
          if (drupal_strlen($node->$field) > $limit) {
            form_set_error($field, t('The !field field has exceeded its maximum number of characters (!limit).', array('!limit' => $limit, '!field' => $field)));
          }
          break;
        }
    }
  }
}
*/
Gabriel R.’s picture

Truncating only the display sounds like the appropriate behavior.

Gabriel R.’s picture

.

cedewey’s picture

Issue summary: View changes
Status: Active » Closed (works as designed)

The Drupal 6 version of Maxlength is no longer supported so I'm marking this Closed (works as designed).

I also encourage you, if you haven't already, to upgrade your site to Drupal 8/9. We are actively maintaining that version and you would enjoy all of the other features of the latest version of Drupal.