仅在某些条件下尝试为 Drupal 显示一个块 - 我尝试写出一些$match = TRUE
内容,以在内容类型是文章或它是存档页面(格式/archive-monthname
)或新闻页面(/news
)之一的情况下允许 a。
由于某种原因,它没有显示在任何所需的页面上。
这是代码:
<?php
$match = FALSE;
$types = array('article' => 1);
if (arg(0) == 'node' && is_numeric(arg(1))) {
$nid = arg(1);
$node = node_load($nid);
$type = $node->type;
if (isset($types[$type])) {
$match = TRUE;
}
}
switch (substr($_SERVER["REQUEST_URI"], 0) {
case "/archive-january":
$match = TRUE;
break;
case "/archive-february":
$match = TRUE;
break;
case "/archive-march":
$match = TRUE;
break;
case "/archive-april":
$match = TRUE;
break;
case "/archive-may":
$match = TRUE;
break;
case "/archive-june":
$match = TRUE;
break;
case "/archive-july":
$match = TRUE;
break;
case "/archive-august":
$match = TRUE;
break;
case "/archive-september":
$match = TRUE;
break;
case "/archive-october":
$match = TRUE;
break;
case "/archive-november":
$match = TRUE;
break;
case "/archive-december":
$match = TRUE;
break;
case "/news":
$match = TRUE;
break;
}
return $match;
?>