I have some errors occuring while using an imagefield title as node title.

I have a content type with just a single imagefield.
I want users to just fill in the image title provided by imagefield. auto nodetitle transfers the image title to node title. If the image title isn't filled i want to use the filename instead. The following code is nearly the same as it is provided in README.TXT (provided by auto nodetitle).

  $token = '[field_image_imagefield-title]';
  if (empty($token)) {
    return '[field_image_imagefield-filename]';
  }
  else {
    return $token;
  } 

It works as expected but i get error messages in my logfile:

  1. Invalid argument supplied for foreach() in [systempath]/modules/node/node.module on line 561.
  2. implode() [<a href='function.implode'>function.implode</a>]: Invalid arguments passed in [systempath]/modules/node/node.module on line 565.
  3. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near &#039;&#039; at line 1 query: SELECT n.nid, n.vid, n.type, n.status, n.created, n.changed, n.comment, n.promote, n.sticky, r.timestamp AS revision_timestamp, r.title, r.body, r.teaser, r.log, r.format, u.uid, u.name, u.picture, u.data FROM node n INNER JOIN users u ON u.uid = n.uid INNER JOIN node_revisions r ON r.vid = n.vid WHERE in [systempath]/includes/database.mysql.inc on line 172.

At this point I don't know if this is a token issue or an automatic nodetitle issue.

Another way to fetch the form values resulted in the same errors. It was done similar to the README.txt again:

global $form_values;
if ($form_values[field_image_imagefield][0]['title'] == "") {
  $name = $form_values[field_image_imagefield][0]['filename'];
} else { 
  $name = $form_values[field_image_imagefield][0]['title'];
}
return $name;

Since this is claimed to not use token i tend to say it is an automatic nodetitle issue.

Maybe this token issue is related:
#282305: Errors when using tokens with modules that are form/node generating content

Any Thoughts?
Thanks, Ronald

Comments

rokr’s picture

The following token reproduces the error messages when set in auto nodetitle ('Pattern for the title:'):

[field_image_imagefield-filename]

field_image_imagefield ist the name of the imagefield in cck.

That simplifies the code above a bit. :-)

cheers, Ronald

drew reece’s picture

Are you using link module? It could be requiring the patch here in post 11.
http://drupal.org/node/285293

Otherwise try replacing the evaluated code with these tokens. I simply got them from the list under the node auto title options. I think cck-image is imagefield module (argh module overload) :-)

[field_image_image-title]
[field_image_image-filename]

The first 'image' should be the name of the actual imagefield.
The error means something is returning empty when it shouldn't be. You could confirm it's the evaluated code by setting the $token = "I SHOUT AT YOU"; and you should see the result after submitting, move it around in the code to see which peice of code is getting used.

Drew

rokr’s picture

At this node type i don't have any link fields and i don't use preview. So i think this is something else.

I DID replace the evaluated code with tokens you suggest (see comment #1). It works for the user but i keep getting error messages in watchdog log.

Thanks, Ronald

drew reece’s picture

I'm unsure where to go from here. I would try disabling the link module just to be 100% sure it is not that module, since it has caused this same error message after a recent update.

You can also add this to the top of the .htaccess file to bring up the errors as they happen. It can sometimes help to backtrack the processes & function calls.

php_flag display_errors on
php_value error_reporting 2047

Don't do it on a live site though.

Is the error just occurring on submission? or is it on viewing too?

rokr’s picture

The error occurs with cck link disabled as expected.
It only occurs while submitting.

ciao, Ronald

rootwork’s picture

I'm pretty sure this is token and not auto_nodetitle as I am getting the same errors and I don't have the latter installed. See #282305: Error when image uploaded. I won't change this to the token issue queue since that one already exists...but I really don't think this is auto_nodetitle.

fago’s picture

Status: Active » Closed (duplicate)

I think so too.