0

I have a menu I would like to be able to style with the Color module. I have found many examples for the Drupal 7 Color module and they have led me to believe that if I just add a line to the 'fields' array in the color.inc file in my theme I will be able to add more regions.

Below is my 'fields' array. I copied an existing file as a guide and simply added my primary menu

'fields' => array(
  'top' => t('Header background top'),
  'bottom' => t('Header background bottom'),
  'primarymenu' => t('Primary navigation menu'),
  'bg' => t('Main background'),
  'sidebar' => t('Sidebar background'),
  'sidebarborders' => t('Sidebar borders'),
  'footer' => t('Footer background'),
  'titleslogan' => t('Title and slogan'),
  'text' => t('Text color'),
  'link' => t('Link color'),
), 

I just added the 'primarymenu' field to the standard bartik array

I realize there is more to do to connect this field to something so it will actually change colors but everything I can find is for D7 and requires altering php templates.

Why is my field not showing up in the appearance settings menu and how do I connect it to change the color of my menu?

Edited To add the schemes array

'schemes' => array(
'default' => array(
  'title' => t('Blue Lagoon (default)'),
  'colors' => array(
    'top' => '#055a8e',
    'bottom' => '#1d84c3',
            'primarymenu' => '#ffffff',
    'bg' => '#ffffff',
    'sidebar' => '#f6f6f2',
    'sidebarborders' => '#f9f9f9',
    'footer' => '#292929',
    'titleslogan' => '#fffeff',
    'text' => '#3b3b3b',
    'link' => '#0071B3',
  ),
),
'firehouse' => array(
  'title' => t('Firehouse'),
  'colors' => array(
    'top' => '#cd2d2d',
    'bottom' => '#d64e4e',
            'primarymenu' => '#ffffff',
    'bg' => '#ffffff',
    'sidebar' => '#f1f4f0',
    'sidebarborders' => '#ededed',
    'footer' => '#1f1d1c',
    'titleslogan' => '#fffeff',
    'text' => '#888888',
    'link' => '#d6121f',
  ),
),
'ice' => array(
  'title' => t('Ice'),
  'colors' => array(
    'top' => '#d0d0d0',
    'bottom' => '#c2c4c5',
            'primarymenu' => '#ffffff',
    'bg' => '#ffffff',
    'sidebar' => '#ffffff',
    'sidebarborders' => '#cccccc',
    'footer' => '#016b83',
    'titleslogan' => '#000000',
    'text' => '#4a4a4a',
    'link' => '#019dbf',
  ),
),
'plum' => array(
  'title' => t('Plum'),
  'colors' => array(
    'top' => '#4c1c58',
    'bottom' => '#593662',
            'primarymenu' => '#ffffff',
    'bg' => '#fffdf7',
    'sidebar' => '#edede7',
    'sidebarborders' => '#e7e7e7',
    'footer' => '#2c2c28',
    'titleslogan' => '#ffffff',
    'text' => '#301313',
    'link' => '#9d408d',
  ),
),
'slate' => array(
  'title' => t('Slate'),
  'colors' => array(
    'top' => '#4a4a4a',
    'bottom' => '#4e4e4e',
            'primarymenu' => '#ffffff',
    'bg' => '#ffffff',
    'sidebar' => '#ffffff',
    'sidebarborders' => '#d0d0d0',
    'footer' => '#161617',
    'titleslogan' => '#ffffff',
    'text' => '#3b3b3b',
    'link' => '#0073b6',
  ),
),

),

2 Answers 2

0

You need to also provide a color for the field you added. In fact, the function that adds the form elements for the color settings contains the following code. (See color_scheme_form().)

 foreach ($palette as $name => $value) {
    if (isset($names[$name])) {
      $form['palette'][$name] = array(
        '#type' => 'textfield',
        '#title' => $names[$name],
        '#value_callback' => 'color_palette_color_value',
        '#default_value' => $value,
        '#size' => 8,
        '#attributes' => array('dir' => LanguageInterface::DIRECTION_LTR),
      );
    }
  }

Without a color value for your field, $form['palette'][$name] will not be added, and it will not be possible to change the color for it.

In fact, the Bartik theme uses the following values, for its default palette.

$info['schemes']['default'] = array(
  'title' => t('Blue Lagoon (default)'),
  'colors' => array(
    'top' => '#055a8e',
    'bottom' => '#1d84c3',
    'bg' => '#ffffff',
    'sidebar' => '#f6f6f2',
    'sidebarborders' => '#f9f9f9',
    'footer' => '#292929',
    'titleslogan' => '#fffeff',
    'text' => '#3b3b3b',
    'link' => '#0071B3',
  ),
);

The keys you find in (for example) $info['schemes']['default']['colors'] are the same keys you find in $info['fields'].

3
  • I added my schemes array as well and pasted the code above, however it still does not show up on my page Feb 24, 2016 at 22:19
  • Which code above?
    – apaderno
    Feb 24, 2016 at 22:23
  • I pasted my schemes array as an edit to the original question Feb 24, 2016 at 22:41
0

I experienced the same issue and after a lot of face-palming, I discovered why the new color field was not showing up.

In my case, I had already saved custom color settings for the original fields before adding my new field. Since the custom settings obviously didn't contain a value for my new field, it was excluded from display in the theme settings. Using the drop-down menu to change back to the default (or some other preset) color scheme solved the issue and then I was able to pick custom colors including the new field.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.