1

I'm in the middle of creating a custom theme using the Bootstrap theme as it's parent. As you may, or may not be aware, the Bootstrap theme comes with lots of useful theme settings. These are great, but as this custom theme will be used for a client, most of these settings could be dangerous for them to be able to change.

I'd like to remove all of these theme settings, so only the ones I add in my custom theme will appear.

I know these theme settings would still be available to change in the Bootstrap theme, but that's not a problem.

Thanks

1

This definitely isn't the nicest solution, but it does work. If you find a better one, do post it here.

function THEMENAME_form_system_theme_settings_alter(&$form, \Drupal\Core\Form\FormStateInterface &$form_state, $form_id = NULL) {
  unset($form['global']);
  unset($form['bootstrap']);
  unset($form['general']);
  unset($form['theme_settings']);
  unset($form['logo']);
  unset($form['favicon']);
  unset($form['components']);
  unset($form['update']);
  unset($form['javascript']);
  unset($form['advanced']);
}
  • 2
    A note on this approach - if your theme relies upon any settings defined in those form elements, the settings effectively get wiped. So, 2 solutions - either make sure your child theme does not rely upon any of those settings, or set some defaults for these values in your hook. – user34185 Jan 6 '17 at 11:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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