Hello :)

I can't make it work:

Firebug: class="block block-block unstyled-block" --- so my block class is not working.

Here my node.tpl.php

<div class="block block-<?php print $block->module; 

unstyled-block" id="block- print $block->module; - print $block->delta; print block_class($block); if (function_exists(block_class)) print block_class($block); ">
if ($block->subject) {

print $block->subject;

}
if ($block->content) {

print $block->content;

}

<?php

In my block settings, I put my name class: "red-block"
CSS class(es) : red-block (no "red-block" or tr.red-block, jsut red-block)

and in style.css:

tr.red-block {
background-color:#D6DFFE;
color: #FF00FF;
}

Do i miss something?

Thanks for the help^^

Comments

junro’s picture

sorry for this display

junro’s picture

<div class="block block-<?php print $block->module; ?> unstyled-block" id="block-<?php print $block->module; ?>-<?php print $block->delta; ?> <?php print block_class($block); ?> <?php if (function_exists(block_class)) print block_class($block); ?>">
  <?php if ($block->subject) { ?><h2 class="title"><?php print $block->subject; ?></h2><?php } ?>
  <?php if ($block->content) { ?><div class="content"><?php print $block->content; ?></div><?php } ?>
</div>
todd nienkerk’s picture

The code should read like this:

<div class="block block-<?php print $block->module; ?> unstyled-block <?php if (function_exists(block_class)) print block_class($block); ?>" id="block-<?php print $block->module; ?>-<?php print $block->delta; ?>">
  <?php if ($block->subject) { ?><h2 class="title"><?php print $block->subject; ?></h2><?php } ?>
  <?php if ($block->content) { ?><div class="content"><?php print $block->content; ?></div><?php } ?>
</div>

You were outputting the block_class module stuff into id="" instead of class="". Also, you were outputting block_class twice.

junro’s picture

ok thanks :) but stil not working.

I put exactly your code and now, with firebug I've got this:

class="block block-block unstyled-block red-block">

I shouldn't have "block-block unstyled-block" anymore.
but only:

class="block red-block" I think.

junro’s picture

hum if I use the block ID for css (#block-block-41), all working well.

What's better for theming blocks? CSS ID or CSS Classes? or it's the same... ?

todd nienkerk’s picture

Junro:

Your CSS is wrong. You're specifying a tr element, which a block is not. The markup shows it's a div, as in <div class="block ..." -- not a tr element. Change your CSS to this:

.red-block {
background-color:#D6DFFE;
color: #FF00FF;
}

Or this:

div.red-block {
background-color:#D6DFFE;
color: #FF00FF;
}

You need to read some basic documentation on CSS before you can get a hang of this. There are lots of CSS guides available online.

Now, regarding the classes that appear in the output, you should ignore block-block. Just trust me on this. unstyled-block appears because you've specifically put it there:

<div class="block block-<?php print $block->module; ?> unstyled-block <?php if (function_exists(block_class)) print block_class($block); ?>" ...

If you don't want unstyled-block to appear, simply remove it from your code.

junro’s picture

Status: Active » Fixed

Oups what a mistake!

Well It's working now thanks ^^

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.