在 TPL 页面上打印内容类型名称


print the content type name on the page tpl

下面的代码将排除内容类型"name"打印在页面和故事类型上。问题,我怎样才能做与此相反的事情,并仅在页面和故事类型上打印内容类型名称?

    <?php
    if (!in_array($node->type, array('story', 'page'))) {
    print node_get_types('name', $node);
    }
    ?>

我删除了(!)并且它可以工作。如何将 css 样式嵌入到此 scprit 中。当我尝试这种方式时,我得到错误。我只需要样式显示在页面或故事类型上。

    <?php
    if (in_array($node->type, array('story', 'page'))) {
    <div class="mystyle">
    print node_get_types('name', $node);
    </div>
    }
    ?>

我在使用"打印"时获得了 css 样式

    <?php
    if (in_array($node->type, array('story', 'page'))) {
    { print '<div class="mystyle"> ';
    print node_get_types('name', $node);
    }
    print '</div>';
    }
    ?>  

假设我正确理解了这个问题,只需删除 not (!) 运算符,例如:

<?php
if (in_array($node->type, array('story', 'page'))) {
     print node_get_types('name', $node);
}
?>

只需删除!运算符:

if (in_array($node->type, array('story', 'page'))) {
  print node_get_types('name', $node);
}