2011-12-21 30 views
1

我在drupal 7中構建了一個站點,遇到了很多問題...這裏對於drupal非常新穎。 我從page.tpl文件中拉出了徽標的php調用,並將其放入要添加到所有頁面的標題塊中。我知道我應該把它留在page.tpl文件中,但認爲使用標題塊是有意義的,但它不再有效。有人可以解釋爲什麼這不起作用嗎?php logo在塊中調用 - Drupal 7

這裏是它的,因爲變量$logo不可用block.tpl.php,它僅提供給page.tpl.php代碼

<div id="logo"><?php if ($logo): ?> 
     <a href="<?php print $front_page; ?>" title="<?php print t('Home'); ?>" rel="home" id="logo"><img src="<?php print $logo; ?>" alt="<?php print t('Home'); ?>" /></a> 
    <?php endif; ?></div> 

回答

2

您可以自己居然搶值是這樣的:

$theme_name = 'name_of_theme'; 
$settings = variable_get('theme_' . $theme_name . '_settings', array()); 

if (isset($settings['logo_path'])) { 
    $logo = file_create_url($settings['logo_path']); 
} 
0

所有你需要的是什麼,這是增加在此的template.php代碼

function hook_preprocess_region(&$variables) { 
    $variables['logo'] = theme_get_setting('logo'); 
    $variables['front_page'] = variable_get('site_frontpage', 'node'); 
} 

清除緩存

和$標誌和$ front_page將起作用。