Hi,
I'm converting the faq module from Drupal 5.x to 6.x. The module has it's own custom type node called 'faq'. This node type is basically the same as a page, but the title has been renamed to "question" and the body to "answer". On the submission of a faq node, the first part of the node content is dropped (up to teaser length) and the following error appears:
notice: Undefined property: stdClass::$teaser_include in /var/www/drupal_6.1_20070924/html/modules/node/node.module on line 740.
The module just has a "faq_form()" function. Since the question text maps to the title, and the answer text maps to the body, I don't have any function to handle the submission of the form. The faq_form() function is :
function faq_form(&$node) {
// question
$form['title'] = array(
'#type' => 'textfield',
'#title' => t('Question'),
'#default_value' => $node->title,
'#required' => TRUE,
'#weight' => 0,
'#description' => t('Question to be answered'),
);
// answer
$form['body_filter']['body'] = array(
'#type' => 'textarea',
'#title' => t('Answer'),
'#default_value' => $node->body,
'#rows' => 20,
'#required' => TRUE,
'#description' => t('This is that answer to the question. It will be filtered according to the input format.'),
);
$form['body_filter']['format'] = filter_form($node->format);
return $form;
}
Can anyone spot what I'm doing wrong? The code is all checked in if you need to have a look through it. All help appreciated!
Cheers,
Stella
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | faq_form_teaser2.patch | 1.62 KB | mwrochna |
| #6 | faq_form_teaser.patch | 1.06 KB | mwrochna |
| #2 | node_notice.patch | 865 bytes | chx |
Comments
Comment #1
stella commentedI've tried the latest drupal 6 code from CVS HEAD and I'm still getting the same error, though the line number has changed to 745.
Just in case you need it, my hook_node_info() is below:
I'm marking this as critical as it's impossible to create new content types with D6. I've gone through the node_example.module for D6 but I haven't found anything that I'm doing wrong. I now think it may be a bug in drupal core.
Cheers,
Stella
Comment #2
chx commentedHardly critical.b
Comment #3
gábor hojtsyThanks, committed.
Comment #4
stella commentedThe patch fixes the warning message, which I agree, by itself isn't a critical issue.
However, my issue was more than just about a warning message. The real problem is that after adding or editing a faq node (essentially the same as the 'page' content type, just different labels), the part of the body text that is within the teaser length is deleted from the
$node->bodyfield. So for a short body content, nothing but the title is displayed, while for longer content, only the text after the teaser length is kept.Perhaps I didn't state it very well, but I did say the following in my issue description.
I thought the error/warning message was part of the same problem, but I've since tried out your patch which fixes the warning message but not my core problem. Now maybe this is a problem with my code, and I have included some functions to show what I'm doing, but I've compared it against the D6 node_example.module code and can't find anything wrong - hence the change from "support request" to "bug report". On the other hand, if this is a bug with drupal core, then I would consider it to be a serious one.
If you need any more information, please let me know.
Cheers,
Stella
Comment #5
stella commentedCan anyone help me here? I still can't find any problem with my code. Could this be a drupal core problem? This issue has now also been reported in #198386.
Cheers,
Stella
Comment #6
mwrochna commentedI don't know much, but I think it's just that faq_form() should call node_body_field() to build body, teaser and filter fields correctly (the way Drupal 6 modules do).
Comment #7
mwrochna commentedoh, and to change the title and body label, this needs to be set in the 'faq node type'.
When updating, admin/content/types/faq >> Submission form settings >> labels needs to be reset to defaults (add a note to README about this?)
Also I'm not sure the body_field's description is necessary.
Comment #8
catchComment #9
stella commentedThanks mwrochna, that works perfectly now. I also see the API docs have been updated with node_body_field(...) method, so thanks again for your help.
Cheers,
Stella
Comment #10
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.
Comment #11
stella commentedReleased in FAQ 6.x-1.3.
Cheers,
Stella