当前位置: 动力学知识库 > 问答 > 编程问答 >

php - Show class only spesific page

问题描述:

I'm using Drupal 7 and my theme is Omega. I have got a class "mask" and its css code:

.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

}

I'm create a class on Omega theme options for show content top but my div show every page. So, i want show this class only node pages.

This is my 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>

Where add my "mask" class in this code?

网友答案:

If you only want this rule to apply ONLY to node types then change it to:

.node .mask {
 ...
}

Drupal adds information about the specific node being viewed as well as the node type in a div in the html. You can use Firebug or just viewing the page html to figure out how you may want to restrict your rule based on the classes present for different content types.

If the content type you want this rule to apply to has a machine name of 'event', for example, you'll see that Drupal adds the class 'node-event' to each node of that type, and you can use that to restrict your rule even further:

.node-event .mask {
 ...
}

Hope that puts you in the right direction!

分享给朋友:
您可能感兴趣的文章:
随机阅读: