0

I noticed that I can get a specific theme setting like so

theme_get_setting('myvar','mytheme');

but I don't see a way of actually setting a setting. Something along the lines of

theme_set_value('myvar','mytheme','value'); I looked at the functions available to me here https://api.drupal.org/api/drupal/core%21includes%21theme.inc/8.2.x but I didn't see anything specific to my needs.

I do see there's already a question asking the same thing here How to set theme setting but that is for Drupal 7 and I'm using 8.

Is there a quick way to set the value of a specific theme setting?

2

Drupal 8 use configuration to store configuration settings. You can follow document. And snippet code to set new value for custom theme(replace theme_name with your theme name).

$config = \Drupal::service('config.factory')->getEditable('theme_name.settings');
$config->set('variable', 'value')->save();

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.