Adding a class after a certain number of blocks

Permalink Browser Info Environment
Might it be possible to add a class after a certain number of blocks?
(e.g. on the fourth block insert a class)

<?php  defined('C5_EXECUTE') or die("Access Denied.");
$nh = Loader::helper('navigation');
?>
<?php
   $count++;
   $classes= "";
   if ( $count == 4 )
   {
      $classes.= " last";
      $count= 0;
   }
?>
<div class="portfolio-item<?php echo $classes; ?>">
...


Please excuse my feeble attempt at the code demo.

Type: Discussion
Status: New
ConcreteCMS
View Replies:
jordanlev replied on at Permalink Reply
jordanlev
There's not an easy way to do this from within the block itself (because a block doesn't have knowledge about other things around it on the page).

But I do have some custom code that lets you set an overall template on the AREA:
https://github.com/jordanlev/c5_block_wrapper_templates...
(Scroll down that page a little to see instructions on installing and using it.)

If you don't want to go through all that trouble, though, then the easiest solution is to use javascript/jquery, maybe something like this:
<script>
$(document).read(function() {
  $('.portfolio-item:eq(3)').addClass('last');
}
</script>

concrete5 Environment Information

Browser User-Agent String

Hide Post Content

This will replace the post content with the message: "Content has been removed by an Administrator"

Hide Content

Request Refund

You have not specified a license for this support ticket. You must have a valid license assigned to a support ticket to request a refund.