Drupal区块只在类型为story的节点中可见

<?php
// Only in content_type = 'story' is visible
$content_type = '';
if(!isset($GLOBALS['content_type'])){
    if(arg(0) == 'node'){
        $sql = sprintf('SELECT type FROM {node} WHERE nid = %d', arg(1));
        $db_result = db_query($sql);
        $resultArr = db_fetch_array($db_result);
        $content_type = $resultArr['type'];
        $GLOBALS['content_type'] = $content_type;
    } else {
        return false;
    }
} else {
    $content_type = $GLOBALS['content_type'];
}
if($content_type == 'story')
    return true;
else
    return false;
?>
在block的设置中把Page specific visibility settings项选为Show if the following PHP code returns TRUE (PHP-mode, experts only).,之后在下面的pages多行框中输入以上代码。

posted @ 2011-01-31 11:45  猫之良品  阅读(374)  评论(0编辑  收藏  举报