我们现在继续,我们看到图片的显示不正常,如图所示:
这是因为图片的路径不对,这是我们使用的html片段:
<img src="images/br.gif" width="253" height="8" />
<img src="images/snt.gif" width="217" height="26" />
<img src="images/xiazai.gif" width="222" height="76" />
我们现在需要将它们调整为这样的形式:
<img src="http://localhost/snt2/sites/all/themes/snt/images/br.gif" width="253" height="8" />
<img src="http://localhost/snt2/sites/all/themes/snt/images/snt.gif" width="217" height="26" />
<img src="http://localhost/snt2/sites/all/themes/snt/images/xiazai.gif" width="222" height="76" />
这是可以工作的,但是,如果我们这样将路径写死在里面的话,将来如果我们更换了域名,此时需要重新的调整这些地址,如果要调整的地方很多,也是非常费力的。
我们可以采用这样的方案,启用核心自带的PHP过滤器模块,在banner-right区块里面,将对应的代码修改为:
<img src="<?php print base_path() . path_to_theme(); ?>/images/br.gif" width="253" height="8" />
<img src="<?php print base_path() . path_to_theme(); ?>/images/snt.gif" width="217" height="26" />
<img src="<?php print base_path() . path_to_theme(); ?>/images/xiazai.gif" width="222" height="76" />
然后将区块正文的文本格式设置为PHP Code,保存。图片的显示就正常了:
注意这里面,这段代码的使用,<?php print base_path() . path_to_theme(); ?>,这是在主题制作、Drupal开发中经常使用的代码。
对于页脚的snt-left区块,我们也做类似的调整:
<img src="<?php print base_path() . path_to_theme(); ?>/images/snt2.gif" width="66" height="25" />