Custom Block, Block Index, Count, view.php

Permalink
Hi,

I have an area defined in a page template: "Client Logos".

Within that area I have added 12 "client logo" (custom blocks).

Is it possible to ouput each block's index / (position within that group of blocks) from the custom blocks view.php file?

In other words, i am trying to end up with the resulting html:

<div class="client-logos"> <!-- Defined in page template -->
<div class="logo group1"></div> <!-- Defined in custom block view.php -->
<div class="logo group2"></div>
<div class="logo group3"></div>
<div class="logo group4"></div>
<div class="logo group5"></div>
<div class="logo group6"></div>
<div class="logo group7"></div>
<div class="logo group8"></div>
<div class="logo group9"></div>
<div class="logo group10"></div>
<div class="logo group11"></div>
<div class="logo group12"></div>
</div>

Thanks for your help.

Best

Dave

 
hutman replied on at Permalink Reply
hutman
You would probably be better off to add something like this to a javascript file in a js folder in your block files, I'm not sure if this will work when you are still in edit mode after adding a block, but once you publish the page it should show everything correctly.

$(document).ready(function() {
    var logoCount = 0;
    $(".client-logos .logo").each(function() {
   logoCount = logoCount + 1;
   $(this).addClass("group"+logoCount);
    });
});