Jump to:

I need help in loading the Flex Slider JS library. The CSS located in drupal_get_path('module', 'flexslider') . '/assets/css/flexslider_img.css loads fine, but there are 2 files that don't load:
libraries_get_path('flexslider') . '/jquery.flexslider-min.js' and
libraries_get_path('flexslider') . '/flexslider.css'

I have used both Flex Slider 7.x-1.x and 7.x-2.x-dev but to no avail.

Got an error when loading the page as well:
Notice: Undefined index: attributes in include() (line 7 of sites/all/modules/flexslider/theme/flexslider.tpl.php).
Recoverable fatal error: Argument 1 passed to drupal_attributes() must be an array, null given, called in sites/all/modules/flexslider/theme/flexslider.tpl.php on line 7 and defined in drupal_attributes() (line 2301 of includes/common.inc).

Also, I have tried to use Drupal default theme and the library still didn't load.

I was having this same problem, and ended up tracking it down to the (now separate) flexslider_views_slideshow module, which IMHO, is using the "correct" way to load the library (drupal_add_library('flexslider', 'flexslider')... but appearently this method no longer works with the flexslider module,

I replaced drupal_add_library('flexslider', 'flexslider'); with flexslider_add() and it worked flawlessly.

We switched to using the hook_libraries_info (as part of the Libraries 2.x) module which is what D8 will be using. Meaning I should update the docs to read "use libraries_load('flexslider')" instead. But you're right, drupal_add_library should still work.

I'll see about reintroducing the basic hook_library which would allow you to include the library as expected.

Thanks for fast response, I dont have time at the moment to prepare a proper patch to add back the hook_library support because I'm preparing now a presentation to be given this week on how to build a responsive slideshow with flexslider, views_slideshow and the bean module.

It would be super cool if the latest dev versions were actually working without needing patches for this presentation, but if not, no big deal. I can provide the one-liner patch to flexslider_views_slideshow for my workaround in #2 if you wish.

Looking at the code in _flexslider_views_slideshow_preprocess_flexslider_views_slideshow_main_frame it looks like there is logic for an optionset, so maybe passing that to flexslider_add() *would* be the proper way to do this... I'm not entirely clear. It looks like some of the optionset logic for the views_slideshow integration really hasn't been built out yet completely, so its really hard for me to tell what would be the proper solution.

Actually, you know what, I do need the hook_library functionality after all, unless there is an alternative way to make hook_library_alter() work.

In a custom feature where all the views and flexslider configs are exported, I'm using hook_library_alter(), to swap out the flexslider.css file with a modified version of my own, and without hook_library() this has pretty much ceased to work.

The big one being Libraries' capacity to find the library in either the sites folder, sites/all or an install profile library folder. There are also lots of options regarding library version numbering, dependencies on specific library versions, etc...

I've got plans to use a good portion of those in the future. Especially as the flexslider library itself is updated/modified. Essentially future proofing the module.

Well, whatever that patch does it made it so flexslider actually works now. It wasn't working at all before applying the patch and I suspected something wasn't working right with the library integration so I figured I would test this patch and sure enough it works. So thank you!

Not 100% sure on this, but this piece of code doesn't seem correct. Usually define() is used when you're hardcoding a value, not pulling it from the database. If my understanding is correct you should remove these two lines, and replace all instances of FLEXSLIDER_DEBUG or FLEXSLIDER_VERSION with variable_get().

Shoot it's been a while and I can't quite remember. I think that I was calling the jQuery library in my html.tpl.php file which was a remnant from the previous slideshow I was using, so I removed that and it worked.

There's also the jQuery Update module that will call jQuery once and you can also set which version of jQuery to use: https://drupal.org/project/jquery_update but I was getting AJAX errors in Views for some reason. It might work for you though.