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.
Comment | File | Size | Author |
---|---|---|---|
#11 | 1929696-drupal_add_library-restore.patch | 3.46 KB | minorOffense |
Comments
Comment #1
minorOffense CreditAttribution: minorOffense commentedHow 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)
Comment #2
jwilson3I 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');
withflexslider_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.
Comment #3
minorOffense CreditAttribution: minorOffense commentedWe 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.
Comment #4
minorOffense CreditAttribution: minorOffense commentedOr a patch is always welcome ;-)
Comment #5
jwilson3Thanks 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.
Comment #6
jwilson3doh.
Comment #7
jwilson3Looking 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 toflexslider_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.Comment #8
jwilson3Actually, 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.
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.
Out of curiosity, what features of the libraries module were needed that the current core D7 library functionality didn't support?
Comment #9
minorOffense CreditAttribution: minorOffense commentedThe 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.
Comment #10
jwilson3If 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:
Comment #11
minorOffense CreditAttribution: minorOffense commentedHere's a patch, care to test it out for me?
Comment #12
jwilson3cool 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.
Comment #13
deggertsen CreditAttribution: deggertsen commentedWell, 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!
Comment #14
gmclelland CreditAttribution: gmclelland commentedPatch in #11 - fixed my issue with flexslider_add() not working when you want to load only the library files manually in your theme.
Comment #15
Tritof CreditAttribution: Tritof commentedPatch in #11 works for me.
Comment #16
jwilson3Not 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 withvariable_get()
.Comment #17
giupenni CreditAttribution: giupenni commentedPatch #11 no works for me.
I have already open a issue http://drupal.org/node/1954886 , I don't know if is it related.
Comment #18
erin814 CreditAttribution: erin814 commentedPatch #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.
Comment #19
orbistertius CreditAttribution: orbistertius commented#18 Could you please explain how you solved it?
Comment #20
erin814 CreditAttribution: erin814 commentedShoot 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.
Comment #21
minorOffense CreditAttribution: minorOffense commentedCommitted #11
Comment #22
stinky CreditAttribution: stinky commented#11 doesn't work for me. I still get "FlexSlider library not found." in the status report.
Comment #23
giupenni CreditAttribution: giupenni commentedIs it fixed in 7.x-2.x-dev?
Comment #24
stinky CreditAttribution: stinky commentedNo. I just installed 7.x-2.x-dev and am still getting
FlexSlider library not found. Please consult the README.txt for installation instructions.
Comment #24.0
stinky CreditAttribution: stinky commentedAdditional error info
Comment #26
nessunluogo CreditAttribution: nessunluogo as a volunteer commentedWith 7.x-2.x-dev and latest Flex Slider library (2.6.0 while I'm writing) the problem is still there.
Using the previous version of the library (2.5.0) seems a fast workaround.
Comment #27
giupenni CreditAttribution: giupenni commentedI'm using latest dev and 2.6.0 library and seems works as I expected.
Are you sure to use JQuery 1.7+ ?
Comment #28
nessunluogo CreditAttribution: nessunluogo as a volunteer commentedI missed that requirement! I'm sure giupenni mean jQuery version 1.7+
Comment #29
Lusha_MHI CreditAttribution: Lusha_MHI commentedI am still having a problem here, I have an updated JQuery, have installed the libraries of both flexslider and libraries API 2, have installed the module, Made sure all of it's dependancies are there and enabled, and it still yells at me. However, It still shows up in configuration, so for now I will ignore it.
However, On a note, if I am to use a patch, Where the heck do I put it? Litterally all I have is an FTP log in and am on windows. I don't know what Drush is, though it appears it is a mac thing...
UPDATE: I dont know is Jquery plug in has anything to do with it, (Though I would assume so, but I will update and make sure that is where it needs to be there. )
Any information on patches would still be appreciated.
Comment #30
jomarocas CreditAttribution: jomarocas as a volunteer commentedok i see very lot of people dont working, and the maintainer tells working, i use latest version of flexslider.2.0rc1 and i use 2.6 version of plugin i supose is the plugin, i install the flexslider in libraries. sites/all/libraries/flexslider and two files
and tells missing flexslider library.
and the only solution is add development library, please update the readme file
Comment #31
Adrião Neves CreditAttribution: Adrião Neves commentedI had this issue and in my case it was related with folder permissions: https://www.drupal.org/node/1351350#comment-6009420