Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/design-patterns/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
page.tpl.php中的Drupal图像_Drupal_Drupal Theming - Fatal编程技术网

page.tpl.php中的Drupal图像

page.tpl.php中的Drupal图像,drupal,drupal-theming,Drupal,Drupal Theming,我是Drupal和Bootstrap的新手,我正在尝试将图像、文本和内容添加到我的站点主体中 我们一直在修改filenamehere>docroot>sites>all>themes>subtheme\u bootstrap>templates中的page.tpl.php文件,以更改站点的主体。除了添加图像,我们在page.tpl.php站点中使用的所有HTML都可以正常工作 为了添加图像,我们在page.tpl.php文件中使用了html标记,如下所示: <div class = "co

我是Drupal和Bootstrap的新手,我正在尝试将图像、文本和内容添加到我的站点主体中

我们一直在修改filenamehere>docroot>sites>all>themes>subtheme\u bootstrap>templates中的page.tpl.php文件,以更改站点的主体。除了添加图像,我们在page.tpl.php站点中使用的所有HTML都可以正常工作

为了添加图像,我们在page.tpl.php文件中使用了html标记
,如下所示:

<div class = "container-fluid">
    <div class = "jumbotron bodygrey">
      <img src="../images/benefits_orange.png" alt="picture" width="300" height="320">
    </div>
</div>


但是,当显示具有正确宽度和高度以及alt标题的图像帧时,图像本身不会显示。我也尝试过添加一个来自网站的链接,以防我放错了目录,但同样的情况也发生了。谁能告诉我怎么了

如上所述,您不能在
页面.tpl.php
中仅在CSS中使用相对路径,因为当呈现HTML时,它试图从站点的根开始查找该图像。相反,您可以使用Drupal
主题(“图像”)
函数,如下所示:

<?php echo theme('image', array('path' => drupal_get_path('theme', 'subtheme_bootstrap') .'/images/benefits_orange.png')); ?>

这将转化为:
/sites/all/themes/subtheme\u bootstrap/images/benefits\u orange.png
在图像路径中使用
$directory
变量。它指向当前的主题目录:

  <img src="<?php print $directory ?>/images/benefits_orange.png" alt="picture" width="300" height="320">
/images/benefits\u orange.png“alt=“picture”width=“300”height=“320”>

检查图像时轻松J

(开发工具),它出现了吗?我打赌路径不正确。是的,它出现了。我还尝试添加一个来自网站的链接作为img src,以防出现问题,但图像也没有出现。那真的很奇怪!目录结构是什么样子的?图像文件是docroot>sites>all>themes>subtheme\u bootstrap>images>benefits_orange.png。php文件是docroot>sites>all>themes>subtheme\u bootstrap>templates>page.tpl.phpy您不能使用显示在不同页面(URL)上的图像的相对路径。您必须在HTML img标记中使用绝对路径。请使用类似