' . t('About') . ''; $output .= '

' . t('Color Field is simple field that use a hexadecimal notation (HEX) for the combination of Red, Green, and Blue color values (RGB). See the Field module help and the Field UI help pages for general information on fields and how to create and manage them. For more information, see the online documentation for the Link module.', array('!field' => Url::fromRoute('help.page', array('name' => 'field')), '!field_ui' => Url::fromRoute('help.page', array('name' => 'field_ui')), '!link_documentation' => 'https://drupal.org/documentation/modules/link')) . '

'; $output .= '

' . t('Uses') . '

'; $output .= '
'; $output .= '
' . t('Managing and displaying color fields') . '
'; $output .= '
' . t('The settings and the display of the link field can be configured separately. See the Field UI help for more information on how to manage fields and their display.', array('!field_ui' => Url::fromRoute('help.page', array('name' => 'field_ui')))) . '
'; $output .= '
' . t('Adding link text') . '
'; $output .= '
' . t('In the field settings you can define additional link text to be optional or required in any link field.') . '
'; $output .= '
' . t('Displaying link text') . '
'; $output .= '
' . t('If link text has been submitted for a URL, then by default this link text is displayed as a link to the URL. If you want to display both the link text and the URL, choose the appropriate link format from the drop-down menu in the Manage display page. If you only want to display the URL even if link text has been submitted, choose Link as the format, and then change its Format settings to display URL only.') . '
'; $output .= '
' . t('Adding attributes to links') . '
'; $output .= '
' . t('You can add attributes to links, by changing the Format settings in the Manage display page. Adding rel="nofollow" notifies search engines that links should not be followed.') . '
'; $output .= '
' . t('Validating URLs') . '
'; $output .= '
' . t('All links are validated after a link field is filled in. They can include anchors or query strings.') . '
'; $output .= '
'; return $output; } } /** * Implements hook_theme(). */ function color_field_theme() { $theme = []; $theme['color_field_formatter_swatch'] = array( 'variables' => array( 'shape' => NULL, 'color' => NULL, 'width' => NULL, 'height' => NULL, ), ); $theme['color_field_widget_box'] = array( 'render element' => 'element', ); $theme['color_field_widget_spectrum'] = array( 'render element' => 'element', ); return $theme; } /** * Prepares variables for the color_field formatter swatch template. * * This template outputs a color swatch. * * Default template: color-field-formatter-swatch.html.twig. * * @param array $variables * An associative array containing: * - color: The color background. * - shape: The shape of the color swatch. * - width: The width of the color swatch. * - height: The height of the color swatch. */ function template_preprocess_color_field_formatter_swatch(&$variables) { } /** * Prepares variables for color_field widget box wrapper template. * * Default template: color-field-widget-box.html.twig. * * @param array $variables * An associative array containing: * - element: An associative array containing the properties of the element. * Properties used: #title, #children, #required, #attributes. */ function template_preprocess_color_field_widget_box(&$variables) { $element = $variables['element']; if (!empty($element['#title'])) { $variables['title'] = $element['#title']; } if (!empty($element['#description'])) { $variables['description'] = $element['#description']; } $variables['color'] = $element['color']; if (!empty($element['opacity'])) { $variables['opacity'] = $element['opacity']; } // Suppress error messages. $variables['errors'] = NULL; if (!empty($element['#description'])) { $variables['description'] = $element['#description']; } $variables['required'] = FALSE; if (!empty($element['#required'])) { $variables['required'] = TRUE; } } /** * Prepares variables for color_field widget box wrapper template. * * Default template: color-field-widget-box.html.twig. * * @param array $variables * An associative array containing: * - element: An associative array containing the properties of the element. * Properties used: #title, #children, #required, #attributes. */ function template_preprocess_color_field_widget_spectrum(&$variables) { $element = $variables['element']; if (!empty($element['#title'])) { $variables['title'] = $element['#title']; } if (!empty($element['#description'])) { $variables['description'] = $element['#description']; } $variables['color'] = $element['color']; if (!empty($element['opacity'])) { $variables['opacity'] = $element['opacity']; } // Suppress error messages. $variables['errors'] = NULL; if (!empty($element['#description'])) { $variables['description'] = $element['#description']; } $variables['required'] = FALSE; if (!empty($element['#required'])) { $variables['required'] = TRUE; } }