Search code examples
phpdrupal-7

To link website logo to external url from backend interface in drupal 7


Need to link website logo to external url from backend interface in drupal 7.

Now I hard coded it to my page.tpl.php file.

Is there any option to add it from backend?


Solution

  • There are no default option for linking website logo to the external URL.

    We need to create a field in the back end for theme settings.

    1. Create a page theme-settings.php just inside theme folder with the following code

      function theme_form_system_theme_settings_alter(&$form, $form_state) {

      $form['theme_settings'] = array(

      '#type' => 'fieldset',
      
      '#title' => t('Theme settings')
      

      );

    $form['theme_settings']['theme_logourl'] = array(

        '#type'          => 'textfield',
    
        '#title'         => t('Logo url'),
    
        '#default_value' => theme_get_setting('theme_logourl'),
    
        '#description'   => t("Logo url for external linking"),
    
      );
      return $form;
    
    }
    
    1. Go and check to the theme settings page - appearance/settings/theme

      There will be a new text filed to enter the external url