Add a class to all blocks added to an Editable area?

Permalink
Hi People

I wonder if this is possible and easy? I have this but it doesn't do what I want?

<section>
<div class="Adverts">
 <?php $a = new Area('Advert Block');$a->display($c) class; ?>
</div>
</section>


Now what I would like is for each block added to the area "Advert Block" to be assigned the class "Adverts" other than the hole area altogether? So I can assign a float left and margin to each block added with the section?

I know I can do this by adding the class manually in the design of the block, I just wondered if it was possible like this?

<section>
 <?php $a = new Area('Advert Block');<div class="Adverts">$a->display($c)</div> 
?>
   </section>


Thanks
CArl

carl101lee
 
synlag replied on at Permalink Reply
synlag
Hi,

it might be possible with some javascript magic to add the class to each block in that area, but as you don't know what the output of the views for the specific blocks is, that might be tricky.
Lets assume each block added is wrapped within a div and has "block" within its ID, you could easily grab them via css from your parent div, that has the class "Adverts"

.adverts > div[id*="block"] {
  // do float to the moon
}


or via jQuery

$('.adverts > [id*="block"]').addClass("holymoly");


Hope it helps

Greets
--ron
mhawke replied on at Permalink Best Answer Reply
mhawke
Simply put this code instead:

<section>
<div class="Adverts">
 <?php
   $a = new Area('Advert Block');
   $a->setBlockWrapperStart('<div class="Adverts">');
   $a->setBlockWrapperEnd('</div>');
   $a->display($c);
 ?>
</div>
</section>


That will wrap each separate block you add to that area with a div with class="Adverts".