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;
| Comment | File | Size | Author |
|---|---|---|---|
| #18 | excerpt.patch | 1.4 KB | giddie |
| #10 | excerpt | 431 bytes | AmrMostafa |
| #5 | msh-2006-07-18.excerpt.module.patch2 | 1.21 KB | Tabbycat |
| #4 | msh-2006-07-18.excerpt.module.patch.txt | 1.26 KB | Tabbycat |
Comments
Comment #1
ec commented+1 for this patch. works fine for me. regards eric.
Comment #2
jmiccolis commentedI 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.
Comment #3
pembeci commentedI 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
validatebut not forsubmitactually, 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.Comment #4
Tabbycat commentedI'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.
Comment #5
Tabbycat commentedOops... 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.
Comment #6
BjornB commentedTabbycat,
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
Comment #7
clashfan commentedHas this issue been fixed.
Comment #8
solipsist commentedWe need this feature too! Any updates?
Comment #9
Caleb G2 commentedThe patch from Tabbycat seems to have gotten in the way of the "read more" link appearing for me. Someone might want to confirm though...
Comment #10
AmrMostafa commentedI 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.
Comment #11
AmrMostafa commentedWould somebody test it please?
Comment #12
mr700 commentedSeems 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.
Comment #13
mr700 commentedOps, I mean I replaced 'validate' with 'submit', not added.
Comment #14
seanbfuller commentedSeconded. The first patch fixes what seems to be an otherwise broken module. RTBC IMHO, but I'll let the maintainers actually flip the status.
Comment #15
David Lesieur commentedWorks for me too. I guess it has been verified by enough people to deserve the RTBC status. :-)
Comment #16
drupalzack commentedTo fix the read-more appearing when the body is less than teaser length, here's my code:
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
Comment #17
drupalzack commentedactually you should remove the view case for readmore ... better than my previous fix
Comment #18
giddie commentedI 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.
Comment #19
chriszz commentedOkay - 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;
Comment #20
giddie commentedYes, 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 :)
Comment #21
hayesr commentedI believe this was fixed a while back.