excerpt.module allows the user to enter a teaser rather than have it be generated automatically. The node_validate() function tests whether a teaser has been supplied before generating one. However, node_preview() omits this test, so previewing a node discards the user's teaser.
Two minor changes to node.module are required to fix this. First, node_preview() needs to test for an existing teaser, just as node_validate() does. Second, node_preview() needs to clear the teaser field after generating the node form, so that edits to the node body will be reflected in the teaser (when excerpt.module is not used).
Patch attached.
| Comment | File | Size | Author |
|---|---|---|---|
| node.module_0.patch | 609 bytes | kps |
Comments
Comment #1
Steven commentedI agree with the first part of your patch, but I'm not sure about this:
"Second, node_preview() needs to clear the teaser field after generating the node form, so that edits to the node body will be reflected in the teaser (when excerpt.module is not used)."
If excerpt.module is not present (or a similar module), then $node->teaser is not stored in the form (as a form_hidden). So after a preview/submit, the teaser is gone again, and will be regenerated. It is only because excerpt.module provides a form_textarea that the teaser is kept across previews/submits.
Comment #2
Steven commentedBy the way, it seems this is a PHP5 issue. Node_preview's parameters are not passed by reference, so in PHP4, the code there does not affect the form. I tested excerpt here, and it worked fine (PHP4).
Comment #3
Steven commentedI committed the isset() check, but left out the unset() because as far as I can tell, it's unnecessary.
Comment #4
kps commentedYes, you're right of course, only the isset() is necessary. (I had been thinking in terms of the old 4.2 teaser behaviour, which I had been copying forward since then.)