Hello,

When I have TSS enabled and I click on preview I get an PHP error:
Warning: Invalid argument supplied for foreach() in /var/www/web/html/site.tld/modules/taxonomy/taxonomy.module on line 70

Kind regards,
nocte

Comments

fourteen40’s picture

I'm getting the same error on a fresh install. Thanks

acb’s picture

Add me as well; not on node-save, but node preview.

neerjasoftwares’s picture

I'm also getting this error with drupal 6.9, i'm getting this error when click on preview node button so please help us to resolve this error.
Please do this on urgent basis.

neerjasoftwares’s picture

I have used "theme_node_preview" into my theme template.php file and change some code in it and this error resolved.

Please use this code if it will solve your problem.

-----------------------

/* Overwrite theme_node_preview function*/

function (your-current-themename)_node_preview($node) {
  $output = '<div class="preview">';
  
  // My added code
  if (!empty($node->taxonomy)) {
  	foreach ($node->taxonomy as $key => $term) {
      // A 'Multiple select' and a 'Free tagging' field returns an array.
	  if (is_array($term)) {
        foreach ($term as $tid) {
			if($tid < 1) continue;
			$taxonomy[$tid] = $tid;
        }
      }
	  $node->taxonomy[$key] = $taxonomy;
    }
  }
  // custom code ends here  

  $preview_trimmed_version = FALSE;
  // Do we need to preview trimmed version of post as well as full version?
  if (isset($node->teaser) && isset($node->body)) {
    $teaser = trim($node->teaser);
    $body = trim(str_replace('<!--break-->', '', $node->body));

    // Preview trimmed version if teaser and body will appear different;
    // also (edge case) if both teaser and body have been specified by the user
    // and are actually the same.
    if ($teaser != $body || ($body && strpos($node->body, '<!--break-->') === 0)) {
      $preview_trimmed_version = TRUE;
    }
  }

  if ($preview_trimmed_version) {
    drupal_set_message(t('The trimmed version of your post shows what your post looks like when promoted to the main page or when exported for syndication.<span class="no-js"> You can insert the delimiter "&lt;!--break--&gt;" (without the quotes) to fine-tune where your post gets split.</span>'));
    $output .= '<h3>'. t('Preview trimmed version') .'</h3>';
    $output .= node_view(drupal_clone($node), 1, FALSE, 0);
    $output .= '<h3>'. t('Preview full version') .'</h3>';
    $output .= node_view($node, 0, FALSE, 0);
  }
  else {
    $output .= node_view($node, 0, FALSE, 0);
  }
  $output .= "</div>\n";

  return $output;
}

// ----------------------------------------------

Please remember to remove site cache.

Annakan’s picture

I can confirm the error on a completely fresh install.

Thanks for the previous hack but I hate to reproduce the whole preview logic just to add such specific code.

And I have a hard time understanding the CAUSE of the problem your hack solve.

It seems to lie in the way freetagings terms are not object in previews but my vocabulary as NO freetaging.

Is it possible to solve the problem at the MODULE level ?

And maybe give an explanation of the problem analysis "neerjasoftwares" did that would help somebody correct the problem at the MODULE level ?

why if($tid < 1) continue; for example ? what's special about negative tid or the zero one ?

thanks a lot for you time.

eresanto’s picture

thelostboy’s picture

subscribe

Gekiboy’s picture

StatusFileSize
new1.1 KB

I had the same issue. Here's a patch I made to fix it for the 6-1 branch

dboulet’s picture

Component: Miscellaneous » Code
Status: Active » Needs review
StatusFileSize
new1.5 KB

Here's an alternative patch, taken from http://drupal.org/node/326614#comment-1866476.

chrisfromredfin’s picture

I don't know if one person counts as "the community" (so not changing status), but patch in #9 seems to work for me.

eli-t’s picture

Patch in #9 works for me too.

keva’s picture

also confirming that patch in #9 works

Ivanhoe123’s picture

Thank you, this worked for me. I'm using taxonomy super select with drupal 6.19

I'd rather use a theme-based patch than to change module files.

This way it will stay on the website even when you update the TSS module.

jcisio’s picture

Status: Needs review » Reviewed & tested by the community

RTBC #9

jcisio’s picture

Status: Reviewed & tested by the community » Closed (fixed)
jcisio’s picture

Status: Closed (fixed) » Fixed

Status: Fixed » Closed (fixed)

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