Hello,

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.

Any suggestions will be appreciated. Thanks.

Files: 
CommentFileSizeAuthor
#11 1929696-drupal_add_library-restore.patch3.46 KBminorOffense
Test request sent.
[ View ]

Comments

Status:Active» Postponed (maintainer needs more info)

How was the module installed? Did you use a make file? Or did you download the FlexSlider library manually. If so, ensure it's in a folder called "flexslider" in a libraries directory

Ex: sites/all/libraries/flexslider

Be sure to use the latest 2.x version from Github with the 2.x version of the module. FlexSlider 1.0-rc3 only works with version 1.x of the library (specifically 1.8 or higher)

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.

Note: running latest dev versions of libraries, flexslider and flexslider_views_slideshow modules.

I don't know what the tradeoff is, or why flexslider doesnt properly load using drupal_add_library(), but perhaps this is something to investigate.

Title:Flexslider library doesn't loaddrupal_add_library('flexslider', 'flexslider') no longer works.
Category:support» bug
Status:Postponed (maintainer needs more info)» Active

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.

Or a patch is always welcome ;-)

Category:bug» support
Status:Active» Postponed (maintainer needs more info)

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.

Category:support» bug
Status:Postponed (maintainer needs more info)» Active

doh.

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.

/**
* Implements hook_library_alter().
*/
function my_feature_library_alter(&$libraries, $module) {
  // Use our own flexslider.css
  if ($module == 'flexslider' && isset($libraries['flexslider'])) {
    $libraries['flexslider']['css'] =  array(
      drupal_get_path('module', 'my_feature') . '/css/flexslider.css' => array(
        'type' => 'file',
        'media' => 'screen',
      ),
    );
  }
}

This will have to be rewritten to use hook_libraries_info_alter instead.
UPDATE: I was able to rewrite this with hook_libraries_info_alter with relative ease.

/**
* Implements hook_libraries_info_alter().
*/
function my_feature_libraries_info_alter(&$libraries) {
  // Use our own flexslider.css
  if (isset($libraries['flexslider'])) {
    array_pop($libraries['flexslider']['files']['css']);
    $libraries['flexslider']['integration files']['my_feature'] =  array(
      'css' => array('css/flexslider.css')
    );
  }
}

Out of curiosity, what features of the libraries module were needed that the current core D7 library functionality didn't support?

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.

If you decide not to add the core library implementation back to regain the drupal_add_library() functionality, you should also update the project page, which currently has broken instructions:

As a library to be used with any other theme or module by calling drupal_add_library('flexslider', 'flexslider')

Status:Active» Needs review
StatusFileSize
new3.46 KB
Test request sent.
[ View ]

Here's a patch, care to test it out for me?

cool thanks for the update, I'm currently on vacation, so can't promise anything until after easter, but will add it to my todo list to check when i get back.

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!

Patch in #11 - fixed my issue with flexslider_add() not working when you want to load only the library files manually in your theme.

Patch in #11 works for me.

Status:Needs review» Needs work

+++ b/flexslider.moduleundefined
@@ -4,6 +4,9 @@
+define("FLEXSLIDER_VERSION", variable_get('flexslider_version', '2.0'));
+define("FLEXSLIDER_DEBUG", variable_get('flexslider_debug', FALSE));

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().

Patch #11 no works for me.

I have already open a issue http://drupal.org/node/1954886 , I don't know if is it related.

Patch #11 didn't work for me. I'm able to see the slideshow in the Views preview but it doesn't show on the live site.

EDIT: I was calling jQuery twice on the live site. Fixed.

#18 Could you please explain how you solved it?

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.

Status:Needs work» Closed (fixed)

Committed #11

#11 doesn't work for me. I still get "FlexSlider library not found." in the status report.

Is it fixed in 7.x-2.x-dev?

No. I just installed 7.x-2.x-dev and am still getting
FlexSlider library not found. Please consult the README.txt for installation instructions.

Issue summary:View changes

Additional error info