I'm currently testing import into a CCK type node that has no "body" field. However, my imported nodes all have a body and teaser fields containing the text: "PLACEHOLDER. CCK needs no body."

How about checking for this and deleting it before node_save?
Or (even better) allowing body to be empty (i.e. not setting an error and failing) if it is a CCK type node?

Comments

dman’s picture

Yeah. That's a limitation from pre-cck days.
I also want to support other node types that may or may not require body. I'm thinking that now that FAPI allows submission from code I should try passing the node creation through that, and allow the FAPI validate to catch all the errors. That would be a bit of surgery however.

Currently I'm doing it by hand at the bottom of _import_html_import_files()

      if (!trim($node->body))
      {
        form_set_error('body', t("No body content found in this node"));
      }

Which is awkward and possibly redundant.
I may try the FAPI validate callback there instead, but I'm concerned that may throw up other complaints - like for undefined required fields or terms - which I've currently been happy to ignore. Because that's easiest.
Either validate fully or use the above cheapo attempt. It's tricky.

leeksoup’s picture

Status: Active » Needs review

I did a simple patch to my copy to make this work. Since the $node->body and teaser are set to placeholder only in the case of a CCK node, it should work for all such nodes. It does work for mine.

Anyway, here's the diff:

1596a1597,1602
>
>       // delete body placeholder from CCK nodes
>       if (preg_match ('/PLACEHOLDER/', $node->body)) {
>         unset ($node->body);
>         unset ($node->teaser);
>       }

Now I don't get junk body and teaser fields on all my imported nodes. :-)

dman’s picture

Status: Needs review » Closed (fixed)

Cleaning up issue queue by closing stuff from the Drupal-5 branch and over a year old.
(This is supported in D6 version)