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

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

stella’s picture

Category: support » bug
Priority: Normal » Critical

I'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:

function faq_node_info() {
  return array(
    'faq' => array(
      'name' => t('FAQ'),
      'module' => 'faq',
      'description' => t('A frequently asked question and its answer.'),
      'has_title' => TRUE,
      'title_label' => t('Question'),
      'has_body' => TRUE,
      'body_label' => t('Answer'),
    )
  );
}

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

chx’s picture

Priority: Critical » Minor
Status: Active » Reviewed & tested by the community
FileSize
865 bytes

Hardly critical.b

Gábor Hojtsy’s picture

Status: Reviewed & tested by the community » Fixed

Thanks, committed.

stella’s picture

Priority: Minor » Normal
Status: Fixed » Needs work

The 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->body field. 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.

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....

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

stella’s picture

Can 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

mwrochna’s picture

Status: Needs work » Needs review
FileSize
1.06 KB

I 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).

mwrochna’s picture

FileSize
1.62 KB

oh, 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.

catch’s picture

Project: Drupal core » Frequently Asked Questions
Version: 6.x-dev » 6.x-1.x-dev
Component: node system » Code
stella’s picture

Status: Needs review » Fixed

Thanks 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

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

stella’s picture

Released in FAQ 6.x-1.3.

Cheers,
Stella