How do I output a table (table-fiel/ragi96) on a layout?

I have been stuck on the spot for hours already. Either I have a comprehension problem or I am looking to find a solution that is not implementable at all.

I am using the table-field plugin from ragi96

The output works perfectly with this code:

block-template:

<?php $table = $page->table()->toTable(); ?>
<?php if ($table != null): ?>
<table>
<?php foreach ($table as $tableRow): ?>
<tr>
<?php foreach ($tableRow as $tableCell): ?>
<td><?=$tableCell; ?></td>
<?php endforeach; ?>
</tr>
<?php endforeach; ?>
</table>
<?php endif; ?>

In a layout, I also use tables.
However, no tables are displayed in the foreach output.

layout-template:

<?php foreach ($page->layout()->toLayouts() as $layout): ?>
<section id="<?= $layout->id() ?>">
<div class="container">
<div class="row">
<?php foreach ($layout->columns() as $column): ?>
<div class="col">
<?= $column->blocks() ?>
</div>
<?php endforeach; ?>
</div>
</div>
</section>
<?php endforeach; ?>

Is it necessary to integrate an additional foreach loop for the table? If yes, at which position?
Or is it not possible, to output tables with the plugin?

If you have created a custom block which uses the table field, you will have to create a block snippet for this custom block. What I don’t understand: If this under block-template is the code for this snippet, why does it use the $page variable instead of $block?

1 Like

… because that was the error! :see_no_evil:
Now it works, as expected.
I had tried almost everything, but I did not recognize this obvious error.
THANKS SO MUCH!