I created my own module, which loads an swf Object similar to the included example.
The following line will throw an error instead of returning some html code:
swfembed.module

return theme('swfembed_embed', $swf) . 'Test' . theme('swfembed_embed', $swf2);

Throws error:
( ! ) Fatal error: Cannot use object of type SWFObject as array in /srv/dev-sites/ernewelt/workspace/cyclodex/www/includes/theme.inc on line 813

Looks like there is an problem with the SWFObject which theme tries to handle as array.
Is it needed to convert the SWF Object before the theme call ?

I have a workaround which just puts the called function code into my own function, without calling theme()... Then it works...

  /*
   * Disabling this call and copy the code of the "theme_swfembed_embed" function
   * code into my own here:
   */


function my_function() {
  $swf = new SWFObject(.......
  ...

  // Theme the object and return that to the client.
  //return theme('swfembed_embed', $swf);

   $swf_object = $swf;

   swfembed_add_js();

   $id = $swf_object->getId();

   $settings['swfembed']['swf'][$id] = $swf_object->toArray();
   drupal_add_js($settings, array('type'=>'setting'));

   return '<div id="' . $id . '">' . $swf_object->getNoFlash() . '</div>';
}

Any hints, ideas, fixes for the real code, regarding the theme call ?

Comments

valderama’s picture

Category: bug » support
Status: Active » Fixed

hey,

The problem is that in Drupal 7 the theme function changed, it now has another signature and awaits an array. See http://api.drupal.org/api/drupal/includes--theme.inc/function/theme/7

change your code to

theme('swfembed_embed', array('swf' => $swf) );

and it should work.

The documentation is not yet up to date, it seems.

Cyclodex’s picture

It works , great ! Thanks for feedback!

Status: Fixed » Closed (fixed)

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

joeysantiago’s picture

I can't make it work neither with the provided code. My version is 7.x-1.4.

$swf = new SWFObject('url_of_my_logo.swf');
  $swf->height(107)
    ->width(190);
//not working
 $content.= "<div class='lft vid'>".theme('swfembed_embed', array('swf' => $swf) )."</div>";
//working
  $content.= "<div class='lft vid'>".theme_swfembed_embed(array('swf'=>$swf))."</div>";

thanks

pelicani’s picture

joey, if you are still having a problem, a year later, please report an error message.
there are many possible explanations.
the swfembed module isn't enabled
the swf location is incorrect
the code in the wrong place
the $content variable is not output

or there may be an unrelated error.
anyway, if you still need help, I hope this helps.

peace,
michael

pelicani’s picture

Issue summary: View changes

renamed the function to a more general name