Problem with "structured data field"

Hi, i have a problem with structured data, i created blueprint, insert data from the panel, stored it into txt, but when i try to “print” the data inside my “structured data field” called “incontri”, the result is that php print 0 and 1 (because there are 2 rows into the data structure)

My blueprint:

  incontri:
    label: Incontri / Appuntamenti / Date
    type: structure
    style: table
    fields:
      appuntamento:
        label: data dell'appuntamento  
        type:  date
        width: 1/2
        required: true
      appuntamento_fine:
        label: data dell'ultimo incontro (solo se "da … a …") 
        type: date
        width: 1/2
      orario:
        label: orario
        type: text

My txt content file:

Incontri: 

- 
  appuntamento: 2019-11-25
  appuntamento_fine: 2019-11-26
  orario: "18.00"
- 
  appuntamento: 2019-11-22
  appuntamento_fine: 2019-11-30
  orario: 19:00

My template:

  	<?php foreach ($page->children() as $children): ?>
  		<?= $children->incontri()->toStructure() ?>
	<?php endforeach ?> 

My result:

"0"
"1" 
(without quotes).

can you help me?
i am an old k2 user, recently passed to k3.

You have to loop through your structure and then call each field, instead you are looping through all pages and I’m not sure that’s what you want to achieve?

<?php foreach ($page->children() as $child): ?>
  <?php $items = $children->incontri()->toStructure() ?>
    <?php foreach ($items as $item) : ?>
    <?= $item->appuntamento()->toDate('Y-m-d') ?>
    <!-- and the otehr fields here -->
    <?php endforeach ?> 
<?php endforeach ?> 

But if you want to fetch the structure field from the current page:


<?php $items = $page->incontri()->toStructure() ?>
<?php foreach ($items as $item) : ?>
    <?= $item->appuntamento()->toDate('Y-m-d') ?>
    <!-- and the otehr fields here -->
<? php endforeach ?> 
1 Like