Drupal - 页面PHP打印图像OK,除非在admin /某些用户页面上

时间:2011-03-22 13:16:08

标签: drupal drupal-theming

以下是我在page.tpl.php中使用的代码:

<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>

对于大多数页面,这可以正常工作,但在管理页面上,图像不会显示。此外,在某些用户页面上(您需要注册才能看到),图像也不会显示。

通过查看页面上的源代码,它看起来是相同的,但它不起作用。

由于

2 个答案:

答案 0 :(得分: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而不是文档根目录

中看到了类似的问题。

答案 1 :(得分: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));