Multiple TOC blocks?

Created on 2 August 2023, 11 months ago
Updated 3 August 2023, 11 months ago

Problem/Motivation

I have a use case (tabs) where i want a TOC on each tab for the content within that tab. I have created a TOC block using the code here: #3264056: How to build a TOC block? β†’ , but modified slightly to allow for multiple blocks. That code would go in to a loop if i didnt add the static var at the top of the code; but for multiple blocks (each with own TOC type) i needed to change to be an array of already rendered blocks so that it would pass through the code multiple times (once per block/toc type), just not repeatedly for each block.

I think this works fine as debugging shows it looping through twice for 2 blocks (i.e. toc types) - but only 1 of them is getting rendered. The block is set to not be cached.

Is it possible something in the toc api code is preventing me from rendering 2 of these on the same page?

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

πŸ’¬ Support request
Status

Closed: works as designed

Version

1.3

Component

Code

Created by

πŸ‡¨πŸ‡¦Canada liquidcms

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @liquidcms
  • Status changed to Closed: works as designed 11 months ago
  • πŸ‡¨πŸ‡¦Canada liquidcms

    This issue is due to how i was rendering my TOC blocks. I suspect when i render content to add block and then render i render again, the first block is lost from the render array.

    I changed how i do this by only rendering the field i am parsing for each toc block and it works fine.

Production build 0.69.0 2024