Reputation: 2710
So I have created a subtheme witch his parent is Drupal Bootstrap theme. I would like to add an option to share a second logo in the page (I have googled but I have found nothing).
As you see in the image, I would like to add the option just where the red line is between "logotip" and "Nom del lloc" and create a variable to acces to the second logo like $second_logo.
Is there a way to do this?
Upvotes: 0
Views: 178
Reputation: 454
I'll edit my answer again, to let you know a complete example to upload a second logo, because it is the proper way to do it Create this file in your custom theme:
theme-settings.php
Use customthemename_form_system_theme_settings_alter(&$form, $form_state) hook
For example:
function customthemename_form_system_theme_settings_alter(&$form, &$form_state, $form_id = NULL) {
$form['second_logo'] = array(
'#type' => 'checkbox',
'#title' => t('Use the second logo'),
'#default_value' => theme_get_setting('second_logo'),
);
Add the variable to youcustomtheme.info file, like this:
settings[second_logo] = ''
Finally, just you can do this in your /sites/all/themes/customthemename/templates/html.tpl.php:
<?php
if (theme_get_setting('second_logo')): ?>
<img src="<?php echo path_to_theme(); ?>/images/your_logo" />
<?php endif;
That's it.
Please refer to the documentation: Theme settings D7
Upvotes: 1
Reputation: 111
implement the below hook "hook_form_system_theme_settings_alter"
function <theme_name>_form_system_theme_settings_alter(&$form, &$form_state, $form_id = NULL) {
//add your variable field
$form['theme_settings']['second_logo'] = array(
'#type' => 'checkbox',
'#title' => t('Use the second logo'),
'#default_value' => theme_get_setting('second_logo'),
);
}
Upvotes: 1