基于 TheodorosPloumis 的答案的更多细节。我最终在我的 template.php 中得到了这样的函数。请注意,您需要更改对 drupal_static 的调用中的“MYTHEME_”以及主函数名称。
<?php
function MYTHEME_preprocess_page(&$vars) {
// Set up logo element
if (at_get_setting('toggle_logo', $theme_name) === 1) {
$vars['site_logo'] = &drupal_static('MYTHEME__preprocess_page_site_logo');
if (empty($vars['site_logo'])) {
$logo_image_alt = check_plain(variable_get('site_name', t('Home page')));
$logo_link = variable_get('logo_link', '<front>');
if (at_get_setting('logo_title') == 1) {
$vars['site_logo'] = $vars['logo_img'] ? l($vars['logo_img'], $logo_link, array('attributes' => array('title' => $logo_image_alt), 'html' => TRUE)) : '';
}
else {
$vars['site_logo'] = $vars['logo_img'] ? l($vars['logo_img'], $logo_link, array('html' => TRUE)) : '';
}
}
// Maintain backwards compatibility with 7.x-2.x sub-themes
$vars['linked_site_logo'] = $vars['site_logo'];
}
}