【发布时间】:2014-11-18 11:07:21
【问题描述】:
我的页面顶部的图片有问题。
当url 是网站名称/菜单时,会显示image。
当url 为网站名称/节点/164 时,image 消失。
所以image在level为1的时候会显示,但是当url-level高于1的时候image就消失了。
我在Drupal-7 上使用ZURB-Foundation 主题。
这是我在page.tpl.php中使用的代码
<!--.page -->
<div role="document" class="page">
<?php
// Create a variable to hold the full path, in our theme, to the image.
// path_to_theme() takes care of creating the correct path for the active theme (which is likely your own custom one)
$my_static_banners = path_to_theme() . '/images/header/';
?>
<?php
if ($handle = opendir(path_to_theme() . '/images/header')) {
/* This is the correct way to loop over the directory. */
while (false !== ($picture = readdir($handle))) {
if($picture != "." && $picture != ".."){
$pictures[] = $picture;
}
}
$random = array_rand($pictures,1);
$header_picture = $pictures[$random];
closedir($handle);
}
?>
<!-- MENU-->
<!--.l-header region -->
<header role="banner" class="l-header" >
<div class="header-image" style="background-image:url(<?php print $my_static_banners.$header_picture ?>)">
</div>
</div>
...
【问题讨论】:
标签: drupal drupal-7 zurb-foundation