I have been trying for quite a while to customize blocks individually within marinelli and I just can't seem to get it to work. I have no problem with drupal core themes and I want to know if this is possible within marinelli. Here's my situation:

I create a block and I want to theme it seperately. Let's say my block selector is 15. I thought I could referance the block with #block-block-15, but it does'nt work. I've looked into the block.tpl.php and I see the defaultblock and blockcontent classes, but changing them changes all blocks. I just want to theme one block individually. Is this possible in marinelli and if so how?

thanks,

wim

Comments

Lioz’s picture

Assigned: Unassigned » Lioz

all blocks use the same container. if you want to customize a particular block you have to edit block.tpl.php with conditional statements: for example: if you have a block with subject=example you can use this code

<?php

if ( ( $block->subject == 'example' ) ) {
	    include 'block-example.tpl.php'; 
	    return; }
	    
    ?>
    
 <div class="defaultblock">
    <h2><?php print $block->subject; ?></h2><!--block title-->
   <div class="blockcontent"><?php print $block->content; ?></div>
</div>

then you have to create a block-example.tpl.php with the html code you want to use

let me know if this solves your problem.

battochir’s picture

Bingo! Thank you Matteo. I was a bit confused by not be able to call blocks by ID, but rather title. Now it's clear to me. I can call any block by simply referencing the title. Problem solved. Nice. I appreciate your help with this.

ciao,

wim

Lioz’s picture

Status: Active » Fixed

ok fixed ;)

Anonymous’s picture

Status: Fixed » Closed (fixed)

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

PepeMty’s picture

subscribing

mikeytown2’s picture

Title: block referancing and custom block design... » block classes
Version: 5.x-1.0 » 6.x-2.9

Change block.tpl.php from <div class="defaultblock"> to <div class="defaultblock block-<?php print $block->module; ?>">. Line 2

jcnventura’s picture

Version: 6.x-2.9 » 6.x-2.96
Status: Closed (fixed) » Active

This is actually a problem in Marinelli not following "core".. Why didn't you copy Garland's block first line:

<div id="block-<?php print $block->module .'-'. $block->delta; ?>" class="clear-block block block-<?php print $block->module ?>">

This provides a simple way for themers to identify and theme each block without having to create their own block.tpl.php, or to add extra lines to the file provided by the theme.

green monkey’s picture

thank you all for this post :))

green monkey’s picture

I ended up moving the code up above the h2 - so I could theme the h2 block too

<div id="block-<?php print $block->module .'-'. $block->delta; ?>" class="clear-block block block-<?php print $block->module ?>">
 <div class="defaultblock">
    <h2><?php print $block->subject; ?></h2><!--block title-->
   <div class="blockcontent"><?php print $block->content; ?></div>
</div>
</div>

again thank you - I was so frustrated with the darn blocks - wow - do I have control now :))

dafeder’s picture

Agreed - no reason not to provide a way to style individual blocks out of the box!

Katrina B’s picture

Subscribing; I was looking for this functionality as well, and I would like to see it become a permanent part of the theme.

tedfeely’s picture

I'm a newbie to Drupal and a notbie (not at all be) to PHP and am trying to get Marinelli blocks to drag and drop.

I replaced Marinelli's block.tpl.php script that follows:

<div id="<?php print $block_html_id; ?>" class="<?php print $classes; ?>"<?php print $attributes; ?>>

  <?php print render($title_prefix); ?>
<?php if ($block->subject): ?>
  <h2<?php print $title_attributes; ?>><?php print $block->subject ?></h2>
<?php endif;?>
  <?php print render($title_suffix); ?>

  <div class="content"<?php print $content_attributes; ?>>
    <?php print $content ?>
  </div>
</div>

. . . with the suggested code listed above:

<div id="block-<?php print $block->module .'-'. $block->delta; ?>" class="clear-block block block-<?php print $block->module ?>">
<div class="defaultblock">
    <h2><?php print $block->subject; ?></h2><!--block title-->
   <div class="blockcontent"><?php print $block->content; ?></div>
</div>
</div>

And, am now getting ubiquitous error messages that say:

Notice: Undefined property: stdClass::$content in include() (line 47 of /home/romeapar/public_html/modules/block/block.tpl.php).

Line 47 is:

print $block->content;

Any help correcting this will be most appreciated.

oadaeh’s picture

Assigned: Lioz » Unassigned
Issue summary: View changes
Status: Active » Closed (won't fix)

This issue is being closed because it is against a branch for a version of Drupal that is no longer supported.
If you feel that this issue is still valid, feel free to re-open and update it (and any possible patch) to work with the 7.x-4.x branch.
Thank you.