Hello team.
I would like to show a gallery of images with the flexslider module in the md-portfolio content
I added two files in the function "function md_portfolio_library ()":
- jquery.flexslider-min.js
- flexslider.load.js
and in the function "function md_portfolio_load_content" I entered
- <script>Drupal.behaviors.flexslider.attach();</script>
done this when I view the contents md-portfolio is blocked and nothing is displayed.
Firebug tells me that there is an error in flexslider.load.js "TypeError: settings is undefined" but I do not have the devout abilities to solve the problem !!
How can I solve the problem and activate flexslider?
Thanks in advance.
Hi,
Please check code file flexslider.load.js, you will see that function attach is declared with 2 parameters: context and settings which are automatically passed in drupal 7
In case you want to call function attach, these 2 parameters should be passed also
For example, Drupal.behaviors.flexslider.attach(document, Drupal.settings);
Hello Cindy,
I did some tests but I did not solve it!
what parameters should I pass to the attach function?
Drupal.behaviors.flexslider.attach(? , ?);
this is the flexslider.load.js
Thank You So Much.
(function($) {
// Behavior to load FlexSlider
Drupal.behaviors.flexslider = {
attach: function(context, settings) {
var id;
var sliders = [];
if ($.type(settings.flexslider) !== 'undefined' && $.type(settings.flexslider.instances) !== 'undefined') {
for (id in settings.flexslider.instances) {
if (settings.flexslider.optionsets[settings.flexslider.instances[id]] !== undefined) {
if (settings.flexslider.optionsets[settings.flexslider.instances[id]].asNavFor !== '') {
// We have to initialize all the sliders which are "asNavFor" first.
_flexslider_init(id, settings.flexslider.optionsets[settings.flexslider.instances[id]], context);
} else {
// Everyone else is second
sliders[id] = settings.flexslider.optionsets[settings.flexslider.instances[id]];
}
}
}
}
// Slider set
for (id in sliders) {
_flexslider_init(id, settings.flexslider.optionsets[settings.flexslider.instances[id]], context);
}
}
};
/**
* Initialize the flexslider instance
*/
function _flexslider_init(id, optionset, context) {
$('#' + id, context).once('flexslider', function() {
// Remove width/height attributes
// @todo load the css path from the settings
$(this).find('ul.slides > li *').removeAttr('width').removeAttr('height');
if (optionset) {
// Add events that developers can use to interact.
$(this).flexslider($.extend(optionset, {
start: function(slider) {
slider.trigger('start', [slider]);
},
before: function(slider) {
slider.trigger('before', [slider]);
},
after: function(slider) {
slider.trigger('after', [slider]);
},
end: function(slider) {
slider.trigger('end', [slider]);
},
added: function(slider) {
slider.trigger('added', [slider]);
},
removed: function(slider) {
slider.trigger('removed', [slider]);
},
init: function(slider) {
slider.trigger('init', [slider]);
}
}));
} else {
$(this).flexslider();
}
});
}
}(jQuery));
You can send us your site url, admin account and FTP account
We will check for you!
We could not log in your FTp account
However, we check page www.officina.pg.it/officina/livevideo and see no problem with the slider in portfolio
http://prntscr.com/j68j4o
http://prntscr.com/j68j9n
Hi,
In function md_portfolio_load_content, we replace:
with:
Check front-end and see no JS error, no blank page
=>slider works correctly now
hi Cindy
I saw that there are no more errors of js, but unfortunately, flexslider still does not work.
with firebug I saw that the images are there but they are all with css rules "display: none;"
I assume that the js files when loading the dom do not work properly.
can you tell me how I can solve?
Thank you.
P:S. if it can help, I noticed that in the file js "Drupal.setting" in the <head>, the fexslider setting references are missing.
Hi,
We check module flexslider and see that there is extra flexslider attribute for object Drupal.settings in function flexslider_add:
You need to add flexslider attribute for cho object Drupal.settings in function md_portfolio_load_content.
We transfered value of Drupal.settings.flexslider in page http://www.officina.pg.it/officina-blog/156 then paste => script $flexs in function md_portfolio_load_content adn the Flexslider works correctly.
Please check the code :
flexslider-1 is the id of tag <div> wrap flexslider
The slider will not work if id is not flexslider-1
You can check function flexslider_add and set value for flexslider attribute for object Drupal.settings in function md_portfolio_load_content
http://www.officina.pg.it/officina-blog/156
WOW is great!! you did it !!
Thanks a lot Cindy