Hi,

I have a content type with "Automatically generate the title and hide the title field" set. In the pattern field I put two fields separated with a whitespace : [node:field_arch_nom] [node:field_arch_firstname]
First field is mandatory, second field is not mandatory.

  1. If the second field is empty then I have a whitespace in the node title (ie: "First field ")
  2. With feeds module, when I import nodes (csv parser), an extra comma and a whitespace is added for each fields in the title (ie: "First field, second field, ").

For my feeds importer, I mapped the title with a column in my csv file.

If auto_nodetitle is not enabled on my content type, the title is correctly set when importing nodes, but when I enable it, the extra comma is added.

Any ideas ?

Thank you

Comments

marqpdx’s picture

I'm getting the same.

i'm not sure if the bug is in this module or in the feeds module.

will keep looking, but any pointers are welcome.
thx

drupix’s picture

Mmhh... If I don't use automatic node title (set the option disabled on content type) then the import works normally, so I'm not sure but I think that the problem is here...

I've try to find the problem unsuccessfully, my investigation stopped in the function _auto_nodetitle_patternprocessor and auto_nodetitle_eval... In case it help

Thank you

marqpdx’s picture

Hi, here's a small update.

It's not just an extra comma, it's two chars, comma and space.

here is some sql i'm using as a post import cleanup, in case it helps:

UPDATE node
SET title = left(title, char_length(title)-2)
where right(title, 2 ) = ', '

thx,
m

drupix’s picture

You're right, there are two chars...

Finally I have implemented hook_node_presave() and removed the comma and the space like this :

if ($node->type=='my_custom_node_type') {
  $title=trim(str_replace(',', '', $node->my_first_field['und'][0]['value']));
  $node->my_first_field['und'][0]['value']=$title;
  //Concatenate my_first_field with my_second_field if not blank
  if (!empty($node->my_second_field['und'])) {
    $firstname=trim(str_replace(',', '', $node->my_second_field['und'][0]['value']));
    $node->my_second_field['und'][0]['value']=$firstname;
    if ($firstname <> '') {
      $title.= ' ' . $firstname;
    }
  }
  $node->title=$title;
}

That solved my problems

drupix’s picture

Issue summary: View changes

better axplanation

manish-31’s picture

Issue summary: View changes
Status: Active » Closed (cannot reproduce)