I’m working on ways to build out tabular data without having to build tables, and structured content with the toStructure()
function has been a lifesaver. However, I’ve run into a snag: The new rows of data don’t line up in a completely tabular fashion. For example, the data might look something like this (this being a sample field from a kirby content page):
training:
-
title: Item 1
detail1: Details about Item 1
detail2: Details about item 1
-
title: Item 2
detail1: Details about item 2
detail2: Details about item 2
detail3: Details about item 2
So what I want to be able to do is call all the detail fields from each structured item, without having to know in advance how many detail items there are for each. What I’ve done previously is called each sub-field, which is all I’ve found instructions for, but somehow I’d like to loop through all the sub-fields for an item (maybe by name, like all that start with detail), and display them, because they won’t all have the same number.
Worst case, I guess, is I can create code to call up to like 5 detail fields, and then only display if they’re not empty. But I’d also like to count them to use that number elsewhere, so that gets more complicated.
Does anybody understand what I’m saying, and can anyone help me with this? Or recommend some method other than structured content for this?