function flexslider_add in Flex Slider 7.2
Same name and namespace in other branches
- 8.2 flexslider.module \flexslider_add()
- 7 flexslider.module \flexslider_add()
2 calls to flexslider_add()
- flexslider.api.php in ./
flexslider.api.php - API documentation for FlexSlider
- template_process_flexslider in theme/
flexslider.theme.inc - Prepares variables for flexslider templates.
File
- ./
flexslider.module, line 372 - A light-weight, customizable image gallery plugin for Drupal based on jQuery
Code
function flexslider_add($id = NULL, $optionset = NULL) {
// Check optionset value
if (is_string($optionset)) {
$name = $optionset;
$optionset = flexslider_optionset_load($name);
if (empty($optionset)) {
watchdog('flexslider', 'Invalid optionset name supplied to flexslider_add: @name', array(
'@name' => $name,
), WATCHDOG_WARNING);
return;
}
}
// Static array to remember which scripts are already attached.
// @todo not currently in use
$cache =& drupal_static(__FUNCTION__, array());
// @todo investigate the best way to cache data loaded from libraries_load()
libraries_load('flexslider');
// If the ID or optionset aren't set, it is assumed the settings will be set
// manually via the calling module/theme
if (!empty($optionset) && !in_array($optionset->name, $cache)) {
$cache[] = $optionset->name;
$js_setting['optionsets'] = array(
$optionset->name => $optionset->options,
);
drupal_add_js(array(
'flexslider' => $js_setting,
), 'setting');
}
if (!empty($id)) {
// JavaScript settings
$js_settings = array(
'instances' => array(
$id => $optionset->name,
),
);
// @todo add alter hook for optionset
drupal_add_js(array(
'flexslider' => $js_settings,
), 'setting');
}
// Loader JavaScript
drupal_add_js(drupal_get_path('module', 'flexslider') . '/assets/js/flexslider.load.js', array(
'type' => 'file',
'scope' => 'footer',
));
}