I'm not crazy about $path = "../../plugins/$plugin_type";. It shouldn't reference the plugins relative to the module, since the module could be in any number of places in the site. I quickly tried $path = base_path() . "/plugins/$plugin_type";, but it did not work and I had to stop. I'll check this out again later.

Comments

davidneedham’s picture

I also tried $path = "/sites/all/plugins/$plugin_type"; and $path = "sites/all/plugins/$plugin_type"; with no luck.

twistor’s picture

I believe you're looking for conf_path().

Awesome idea by the way.

twistor’s picture

remove dupe.

davidneedham’s picture

@twistor: Hmm, when I dsm(conf_path()), I only get sites/default. Thanks for the tip though!

davidneedham’s picture

I also tried using DRUPAL_ROOT with no luck. So far, only ../../plugins/$plugin_type works.

twistor’s picture

Yeah, I'm thinking that ctools automatically adds the module path in front.

twistor’s picture

The problem with ../../plugins/$plugin_type is that it won't work if your modules are in another directory. eg. modules/contrib/add_plugins. I think the only way you can do this effectively is to figure out the directory you're in and walk up to the directory you want to put the plugins folder in.

davidneedham’s picture

Issue summary: View changes
Status: Postponed » Closed (fixed)

The module has been rewritten from the ground up (not that there was much to start with). It now borrows a function from the Libraries module to locate the most specific plugins directory in any of the standard locations (/plugins, sites/all/plugins and sites/example.com/plugins). It then compares the path to the module (wherever the module is) to the path of the plugins folder, creates a path and passes that on to ctools.