Cannot use object of type stdClass Media gallery


Author Message
Daniel

Posted: 4/5/2011
Quote message 

I use the media_gallery module, now using a artisteer-theme I get this message trying to display my galleries.


Cannot use object of type stdClass as array in C:\Entwicklung\drupal-7.0\sites\all\themes\classic_v1\drupal7_theme_methods.php on line 247



Line 247 looks like this:
$field_type = isset($content[$name]['#field_type']) ? $content[$name]['#field_type'] : NULL; 

 
Bucket

Posted: 5/27/2011
Quote message 

It's an error that occurs when the referenced $content[$name] is actually an object.

See this article: http://www.wallpaperama.com/forums/howto-fix-fatal-error-cannot-use-object-of-type-stdclass-as-array-in-php-t1735.html

For a quick fix add a test condition :

if (!is_object($content[$name])) {
$field_type = isset($content[$name]['#field_type']) ? $content[$name]['#field_type'] : NULL;
}

worked for me.



 
Gert

Posted: 2/17/2012
Quote message 

Hi

Does it matter where you add this code, because it isn't working for me.

Thanks

Gert