replace the following:

case 'validate':
      if (trim($node->teaser) == '') {
        $node->teaser = node_teaser($node->body);
      }
      break;

with:

  case 'submit':
      if (trim($node->teaser) == '') {
        $node->teaser = node_teaser($node->body);
      }
      break;

Comments

ec’s picture

+1 for this patch. works fine for me. regards eric.

jmiccolis’s picture

I can confirm the bug, and this fix does create proper teasers - but it doesn't quite do it for me, because preview still doesn't work.

pembeci’s picture

I am experiencing the same problem in 4.7. The above patch fixes the problem partially but I don't think it is the rigth solution (hook_nodeapi has an operation validate but not for submit actually, according to the documentation) so the previews do not work. Additionally, for short posts (when the teaser is equivalent to node body) there is still a read more link.

Tabbycat’s picture

StatusFileSize
new1.26 KB

I am experiencing the same problem in 4.7. The above patch fixes the problem partially but I don't think it is the rigth solution (hook_nodeapi has an operation validate but not for submit actually, according to the documentation) so the previews do not work. Additionally, for short posts (when the teaser is equivalent to node body) there is still a read more link.

I'm fairly new to Drupal (only picked it up last week) but from looking at the API for drupal 4.7.2 it seems that the documentation for hook_nodeapi is slightly out of date. When drupal calls the validation hook functions it passes in a copy of the submitted data, such that any changes made during the validation hooks to the node will only be visible during the validation hooks and will revert after they've run. There is a new submit hook present (which isn't mentioned in the hook_nodeapi docs).

I've made my own patch to apply to the current 4.7.0 version of excerpt that sets the teaser if none was input, but also shows the teaser entry box as blank if the current teaser is an auto-generated one (instead of showing the auto-generated teaser) such that if you're using an autogenerated teaser you don't have to keep pasting updates into the teaser box each time.

Alas the auto-generated teaser doesn't show up in the preview. This is because drupal hooks the hook_nodeapi hook for validate but not for submit when generating the preview, and because the validate hook again passes in a copy of the submitted data it then reverts to its pre-hook state when it's then shown for preview.

Tabbycat’s picture

StatusFileSize
new1.21 KB

Oops... quick followup to my previous post and a better patch.

After a bit more digging around in the documention I've discovered that you can update form values in the validate hook - you just need to use the form_set_value function instead.

Here is a revised patch that has working previews too.

BjornB’s picture

Tabbycat,

When I patch with your patch I receive this error when Auto-generated teaser is enabled in forum postings.

warning: array_shift(): The argument should be an array in /home/xxxxxx/public_html/site/includes/form.inc on line 487.

drupal 4.7.3

clashfan’s picture

Has this issue been fixed.

solipsist’s picture

We need this feature too! Any updates?

Caleb G2’s picture

The patch from Tabbycat seems to have gotten in the way of the "read more" link appearing for me. Someone might want to confirm though...

AmrMostafa’s picture

StatusFileSize
new431 bytes

I think all what's really required was posted by freeq80, you just replace 'validate' with 'submit'. my .02$.
attached the required modification as a patch.

AmrMostafa’s picture

Status: Reviewed & tested by the community » Needs review

Would somebody test it please?

mr700’s picture

Seems to work for me, we never post anything without explictly entered teaser/excerpt, but when I post something without teaser/excerpt I see only the node's title on the front page. Adding 'submit' to _nodeapi's case fixes it.

mr700’s picture

Ops, I mean I replaced 'validate' with 'submit', not added.

seanbfuller’s picture

Seconded. The first patch fixes what seems to be an otherwise broken module. RTBC IMHO, but I'll let the maintainers actually flip the status.

David Lesieur’s picture

Status: Needs review » Reviewed & tested by the community

Works for me too. I guess it has been verified by enough people to deserve the RTBC status. :-)

drupalzack’s picture

To fix the read-more appearing when the body is less than teaser length, here's my code:

function excerpt_nodeapi(&$node, $op, $arg) {
  switch ($op) {
   case 'validate':
   case 'submit':
      if (trim($node->teaser) == '') {
        $node->teaser = node_teaser($node->body);
      }
      break;
    case 'view':
      
      $node->readmore = strlen(trim($node->teaser)) != strlen(trim($node->body));
      break;
  }
}

Only remaining bug is when there is no teaser and the body is greater than teaser length, when you do a preview, it doesn't show the trimmed post (but works on submit). Let me see if I can fix this... or if someone else has a fix, will be glad to hear about it!

Such a lovely module, can't understand why there isn't more activity

drupalzack’s picture

actually you should remove the view case for readmore ... better than my previous fix

giddie’s picture

StatusFileSize
new1.4 KB

I managed to fix this for me by using a combination of the above patches. My patch is attached.

I'm using Drupal 5.3, excerpt 5.x-1.x-dev.

chriszz’s picture

Version: 4.7.x-1.x-dev » 5.x-1.x-dev

Okay - this would be ready for 5. - ain't it?

Why did you cut this off? Is this handled by drupal automatically?

- case 'view':
- $node->readmore = $node->teaser != $node->body;
- break;

giddie’s picture

Yes, it would appear that it's handled automatically. To be honest I haven't looked into it too much. It works better without it anyway :)

hayesr’s picture

Status: Reviewed & tested by the community » Closed (fixed)

I believe this was fixed a while back.