In the swfobject_api_nodeapi declaration, you have an if-else clause that (if the condition is satisfied) results in:

drupal_add_js(drupal_get_path('module','swfobject_api') . "/swfobject.js");

However, it does not do anything. I have Drupal 5.1 and the latest build of swfobject_api (Jan 2007), and when I invoke the API in a module, it correctly writes all the HTML and JavaScript into the page, but I get the "Sorry, you need to install flash to see this content." and when I view the page source, the js file was never loaded. The drupal_add_js line is never being reached. I was able to work around this by simply lifting the whole line out of the if-else construct and dumping up near the top of the function so it runs every single time, but obviously that's horrible.

Also, what's with the "swfobject_api_create" function? Is is used for anything?

Would love to get this stuff ironed out, because this could be a crucial module, appreciated by a lot of people.

Comments

stuffnthings’s picture

I am not sure why this is happening either, but I am getting a log error message that says
warning page not found 04/21/2008 - 12:43 modules/swfobject_api/swfobject.js

arthurf’s picture

Status: Active » Fixed

I've just committed a new version that should address this.

Anonymous’s picture

Status: Fixed » Closed (fixed)

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

levelos’s picture

Title: swfobject.js not being added by drupal_add_js » what was the cause?

I am using 2.0-beta1 and the latest swfobject.js file from the Google Code and am still seeing this behavior. I've tried tossing in drupal_add_js in several places and it just won't add the swfobject.js file. What gives?

levelos’s picture

In case this is helpful to others, I discovered the problem to be a page life cycle one. The JS files were added only if the function is called in _phptemplate_variables or just procedurally in the template.php file. Other calls in the template, either in the tpl.php files themselves for a later life cycle call in template.php are too late to add the JS files.