2011-03-22 60 views
0

下面是被使用在我的page.tpl.php中的代碼IVE:Drupal的 - PHP頁打印圖像OK,除非管理員/某些用戶頁面

<div id="beforefooter"> 
<?php print l('<img src="imagesmy/logo.jpg" />', '<front>', array('html' => TRUE)); ?> 
</div> 

<div id="afterfooter"> 
    <a href="http://www.site.com" target="_blank" > 
     <img src="imagesmy/credit.jpg" /> 
    </a> 
</div> 

對於大多數的網頁能正常工作,但是當上管理員頁面的圖像不顯示。同樣在某些用戶頁面上(您需要註冊才能看到),圖像也不顯示。

從查看頁面上的源代碼,它看起來是相同的,當它並沒有工作。

感謝

回答

0

嘗試使用base_path()$base_path

print l('<img src="' . base_path() . 'imagesmy/logo.jpg" />', '<front>', array('html' => TRUE));

是路徑到圖像上的不同的頁面完全一樣?我看到一個類似的問題,它試圖找到圖像在「www.example.com/admin/imagesmy/logo.jpg而不是在文檔根目錄

+0

我怎樣才能在DIV#第二個鏈接afterfooter工作?我用盡從第一適應你的代碼,但我一定是做了錯誤的。謝謝 – Evans 2011-03-22 14:17:04

+0

' print'('','http://www.site.com',array('html'=> TRUE));'應該可以工作 – Laxman13 2011-03-22 14:20:33

+0

Working: Evans 2011-03-22 14:20:35

0

您也可以嘗試使用drupal_get_path()構建您的圖像,它會一定要解決,爲圖像的正確位置。

$img_path = drupal_get_path('theme', 'name-of-your-theme') . '/images/logo.png'; 
$img = theme('image', $img_path, 'the-alt-text', 'the-title-text'); 
print l($img, '<front>', array('html' => TRUE)); 
相關問題