function hook_widgets_sets_alter in Widgets 7
Modify any image sets provided by other modules or the user.
This hook allows modules to modify, add, or remove image sets. This may be useful to modify default sets provided by other modules or enforce that a specific element is always enabled on a set. Note that modifications to these sets may negatively affect the user experience, such as if an element is added to a set through this hook, the user may attempt to remove the element but it will be immediately be re-added.
The best use of this hook is usually to modify default sets, which are not editable by the user until they are overridden, so such interface contradictions will not occur. This hook can target default (or user) sets by checking the $set['storage'] property.
If your module needs to provide a new set (rather than modify an existing one) use hook_widgets_default_sets() instead.
See also
1 invocation of hook_widgets_sets_alter()
- widgets_sets in ./
widgets.module - Get an array of all sets and their settings.
File
- ./
widgets.api.php, line 144 - Hooks related to widget sets and widgets. TODO: Update API docs NOTICE: This file has been copied from the image module and has not been updated for use with Widgets yet.
Code
function hook_widgets_sets_alter(&$sets) {
// Check that we only affect a default set.
if ($sets['thumbnail']['storage'] == widgets_STORAGE_DEFAULT) {
// Add an additional element to the thumbnail set.
$sets['thumbnail']['elements'][] = array(
'name' => 'widgets_desaturate',
'data' => array(),
'weight' => 1,
'element callback' => 'widgets_desaturate_element',
);
}
}