0

I need to save in theme 2 custom logos and use them on the site. Can I somehow create custom field in theme or maybe save the path to another logo in one of the .yml theme files?

0

Created theme-settings.php in custom theme root, there created new function, it renders new fieldset and a managed_file field

function theme_name_form_system_theme_settings_alter(array &$form, FormStateInterface $form_state) {
  $form['options_settings'] = [
    '#type' => 'fieldset',
    '#title' => t('Theme Specific Settings'),
  ];

  $form['options_settings']['add_logo'] = [
    '#type' => 'managed_file',
    '#title' => t('Additional logo'),
    '#upload_location' => 'public://logo/',
    '#default_value' => theme_get_setting('add_logo'),
    '#states' => [
      'visible' => [
        ':input[name="File_type"]' => ['value' => t('Upload Your File')],
      ],
    ],
  ];
}

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.