I'm porting cluetips to D6 and making it a JQ module.

Cluetips zip comes with all the JS files it needs (hoverIntent and dimensions), currently the module just uses them, however i would love it, if it could work out if a JQ module exists to take over the work and use that file instead (if avilable).

The problem is the jq_plugins() function. We need to call it in the MODULENAME_jq() hook, to assess if the local files for hoverIntent need to be used, but in calling jq_plugins() it triggers its own hook again, causing a loop.

Any nice way around this? or have i missed the point?

Comments

avpaderno’s picture

If you are porting the module to Drupal 6, you should know that the dimensions plugin is already included within jQuery 1.2.6 used by Drupal 6 (see the jQuery 1.2.6 release notes on Dimensions Plugin is Now Part of Core).

avpaderno’s picture

If what you want to do is to check if a plugin is available, before to use your own version of the plugin, you can call jq_add() which returns a value useful to understand if the function has been able to load the required plugin (therefore, the plugin is already available).

avpaderno’s picture

Title: How can i check if a module is already installed? » How can i check if a plugin is already available?

I am changing the request title, as it seemed you were asking how to generally check if a module is available (which would lead somebody to reply with call module_exists()).

avpaderno’s picture

Title: How can i check if a plugin is already available? » How can I check if a plugin is already available?
guillaumeduveau’s picture

Would this work ?

if ( !empty(jq_plugins('your_plugin') ) {
  ...
}
guillaumeduveau’s picture

Oups that was producing a fatal PHP error. Use

if ( in_array('your_plugin', jq_plugins()) ) {
...
}

ball.in.th’s picture

I believe the correct syntax for #6 would be:

if (array_key_exists('cycle', jq_plugins())) {
}

Though it doesn't seem to be necessary because you can just check the return value of jq_add('your_plugin'); .

guillaumeduveau’s picture

@ #7 if I remember well this is not right when the module is unavailable, since it adds a warning in watchdog.

avpaderno’s picture

  if (module_exists('jq') && array_key_exists('cycle', jq_plugins())) {
    // ...
  }
avpaderno’s picture

Issue summary: View changes
Status: Active » Closed (outdated)

I am closing this issue since it's for a Drupal version that isn't supported.