仅显示类特定页面

时间:2012-04-26 12:59:53

标签: php drupal drupal-templates drupal-nodes

我正在使用Drupal 7,我的主题是Omega。我有一个类“掩码”及其css代码:

.mask {
    background:url("../img/header_mask.png") repeat-x scroll 0 0 transparent;
    height:200px;
    position:absolute;
    top:0;
    width:100%!important;
    z-index:101
}

我正在为节目内容创建一个关于Omega主题选项的课程,但我的div显示每个页面。所以,我想要只显示这个类的节点页面。

这是我的node.tpl.php:

<div id="node-<?php print $node->nid; ?>" class="<?php print $classes; ?> clearfix"<?php print $attributes; ?>>

  <?php print $user_picture; ?>

  <?php print render($title_prefix); ?>
  <?php if (!$page): ?>
    <h2<?php print $title_attributes; ?>><a href="<?php print $node_url; ?>"><?php print $title; ?></a></h2>
  <?php endif; ?>
  <?php print render($title_suffix); ?>

  <?php if ($display_submitted): ?>
    <div class="submitted">
      <?php print $submitted; ?>
    </div>
  <?php endif; ?>

  <div class="content"<?php print $content_attributes; ?>>
    <?php
      // We hide the comments and links now so that we can render them later.
      hide($content['comments']);
      hide($content['links']);
      print render($content);
    ?>
  </div>

  <?php print render($content['links']); ?>

  <?php print render($content['comments']); ?>

</div>

在此代码中添加我的“mask”类?

1 个答案:

答案 0 :(得分:0)

如果您只希望此规则仅应用于节点类型,请将其更改为:

.node .mask {
 ...
}

Drupal添加有关正在查看的特定节点的信息以及html中div中的节点类型。您可以使用Firebug或仅查看页面html,根据不同内容类型的类别来确定如何限制规则。

例如,如果要应用此规则的内容类型的计算机名称为“event”,您将看到Drupal将类“node-event”添加到该类型的每个节点,您可以用它来进一步限制你的规则:

.node-event .mask {
 ...
}

希望能让你朝着正确的方向前进!

相关问题