function styles_default_styles in Styles 6.2
Same name and namespace in other branches
- 7.2 styles.module \styles_default_styles()
Return all available styles for a specific field type.
Each style under a field type should be an associative array with the following optional keys: 'label' => An untranslated human readable title for the style. 'description' => An untranslated human readable description for the style. 'default theme' => The theme to call for display if there is no preset returned when filtering the field. 'default theme arguments' => Any arguments to pass after the first (of the field's object itself).
Example implementation of hook_styles_default_styles(): array( 'nodereference' => array( 'styles' => array( 'thumbnail' => array( 'label' => 'Thumbnail', 'description' => 'Representative thumbnails linking to the content page.', 'default theme' => 'my_styles_default_thumbnail', ), 'small' => array( 'label' => 'Small', 'description' => 'Small images linking to the content page.', 'default theme' => 'my_styles_default_thumbnail', ), 'teaser' => array( 'label' => 'Teaser', 'description' => 'A short summary of the content.', 'default theme' => 'node_view', 'default theme arguments' => array(TRUE), ), ), ), );
This will create those styles, allowing
Parameters
string $field_type: (Optional) The field type, such as filefield or nodereference.
boolean $reset: (Optional) If TRUE, then we reset the cache.
4 calls to styles_default_styles()
- styles_default_presets in ./
styles.module - Return all available presets for field type containers.
- styles_field_formatter_info in ./
styles.module - Implements CCK's hook_field_formatter_info().
- styles_instance in ./
styles.module - styles_theme in ./
styles.module - Implements hook_theme().
File
- ./
styles.module, line 183 - styles.module Styles
Code
function styles_default_styles($return_type = NULL, $reset = FALSE) {
$styles =& _styles_drupal_static(__FUNCTION__);
// Grab from cache or build the array.
if (!isset($styles) || $reset) {
if (($cache = cache_get('styles_default_styles', 'cache')) && !$reset) {
$styles = $cache->data;
}
else {
$styles = array();
styles_module_load_all_includes();
foreach (module_implements('styles_default_styles') as $module) {
$module_styles = module_invoke($module, 'styles_default_styles');
foreach ($module_styles as $field_type => $container) {
$styles[$field_type] = $container;
foreach ($container['styles'] as $style_name => $style) {
$style['name'] = $style_name;
$style['module'] = $module;
$style['storage'] = STYLES_STORAGE_DEFAULT;
$styles[$field_type]['styles'][$style_name] = $style;
}
}
}
// @TODO: Add user styles next.
drupal_alter('styles_default_styles', $styles);
cache_set('styles_default_styles', $styles);
}
}
if (isset($return_type)) {
return $styles[$return_type];
}
return $styles;
}