Forum

Thread tagged as: Question

Can I count inside blocks?

Using blocks to create sections on a single page site and using the title of each block to create the page menu. However, I'd like to display the count:

  1. Item
  2. Item
  3. Item
  4. Item ...

Is it possible to output the count as I loop through the blocks:

    <perch:blocks>
      <perch:block type="text" label="Text">
        <li class="active"><span class="num">1</span><span class="text"><perch:content id="text_block_title" /></span></li>
      </perch:block>
    </perch:blocks>
David Powell

David Powell 0 points

  • 3 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Have you checked the output of <perch:showall /> ? I think there's a count.

Doing that shows I have access to _block_index which would be fine but it start with 0. I could manipulate it with JS but that's not ideal...

Drew McLellan

Drew McLellan 2638 points
Perch Support

You can adjust it with a template filter.