I followed the documentation on drupal.org to add a field to the theme-settings.php but there must be a mistake in code.
I have a filed called advertisement and a theme called tv so I tried to copy and paste the code and altered the names where to alter theme the files I created in particular are as follows:
/themes/tv/templates/system/thme-settings.php
#}
function tv_form_system_theme_settings_alter(&$form,
\Drupal\Core\Form\FormStateInterface &$form_state, $form_id = NULL) {
// Work-around for a core bug affecting admin themes. See issue
#943212.
if (isset($form_id)) {
return;
$form['tv_advertisement'] = array(
'#type' => 'textfield',
'#title' => t('Widget'),
'#default_value' => theme_get_setting('tv_advertisement'),
'#description' => t("Place this text in the widget spot on your
site."),
);
}
$tv_advertisement = theme_get_setting('tv_advertisement');
in /themes/tv/config/install/tv.settings.yml I put this:
tv_advertisement: blue bikeshed
My /themes/tv/tv.theme file contains:
<?php
/**
* @file
* Theme functions
*/
// Include all files from the includes directory.
$includes_path = dirname(__FILE__) . '/includes/*.inc';
foreach (glob($includes_path) as $filename) {
require_once dirname(__FILE__) . '/includes/' . basename($filename);
}
function tv_preprocess_node(&$variables) {
$variables['tv_advertisement'] =
theme_get_setting('tv_advertisement');
}
The last thing I did was
drush cr
to clear the cache
When I go to the themes settings page there are only the default fieds displayed but the new one does not show up
If anyone has a clue what I am doing wrong and is able to enlighten me I would be very pleased.
Thank you