I use the Structure field on multiple pages of different websites. Having added a new Structure field to a page, I’m getting an error I haven’t seen before and I can’t figure out what is wrong. (The same website already has two other Structures working perfectly.)
Everything works fine in the Panel but, for thoroughness, the blueprint setup is a follows…
fields:
bulletin:
label: Bulletin board
type: structure
columns:
headline:
fields:
headline:
type: text
text:
type: writer
I have checked my snippet’s PHP code against the working examples and they are exactly the same except for the field names. I cannot see where the issue is…
<?php $items = $page->bulletin()->toStructure(); $n = 0; foreach ($items as $item): $n++; ?>
<?php if ($item->headline()->isNotEmpty()): ?><h4><?= $item->headline() ?></h4><?php endif ?>
<?php if ($item->text()->isNotEmpty()): ?><?= $item->text() ?><?php endif ?>
<?php endforeach ?>
The error I am getting is as follows…
TypeError thrown with message "Kirby\Content\Content::__construct(): Argument #1 ($data) must be of type array, string given, called in C:\xampp\htdocs\projects\wendoverds\kirby\src\Cms\StructureObject.php on line 38"
Stacktrace:
#26 TypeError in C:\xampp\htdocs\projects\wendoverds\kirby\src\Content\Content.php:55
#25 Kirby\Content\Content:__construct in C:\xampp\htdocs\projects\wendoverds\kirby\src\Cms\StructureObject.php:38
#24 Kirby\Cms\StructureObject:__construct in C:\xampp\htdocs\projects\wendoverds\kirby\src\Cms\Item.php:55
#23 Kirby\Cms\Item:factory in C:\xampp\htdocs\projects\wendoverds\kirby\src\Cms\Items.php:78
#22 Kirby\Cms\Items:factory in C:\xampp\htdocs\projects\wendoverds\kirby\src\Cms\Structure.php:47
#21 Kirby\Cms\Structure:factory in C:\xampp\htdocs\projects\wendoverds\kirby\config\methods.php:258
#20 Kirby\Cms\Core:{closure} in C:\xampp\htdocs\projects\wendoverds\kirby\src\Content\Field.php:78
#19 Kirby\Content\Field:__call in C:\xampp\htdocs\projects\wendoverds\site\snippets\banner_home.php:23
#18 include in C:\xampp\htdocs\projects\wendoverds\kirby\src\Filesystem\F.php:425
#17 Kirby\Filesystem\F:loadIsolated in C:\xampp\htdocs\projects\wendoverds\kirby\src\Filesystem\F.php:364
#16 Kirby\Filesystem\F:Kirby\Filesystem\{closure} in C:\xampp\htdocs\projects\wendoverds\kirby\src\Filesystem\F.php:372
#15 Kirby\Filesystem\F:load in C:\xampp\htdocs\projects\wendoverds\kirby\src\Toolkit\Tpl.php:36
#14 Kirby\Toolkit\Tpl:load in C:\xampp\htdocs\projects\wendoverds\kirby\src\Template\Snippet.php:172
#13 Kirby\Template\Snippet:factory in C:\xampp\htdocs\projects\wendoverds\kirby\config\components.php:301
#12 Kirby\Cms\Core:{closure} in C:\xampp\htdocs\projects\wendoverds\kirby\src\Cms\App.php:1553
#11 Kirby\Cms\App:snippet in C:\xampp\htdocs\projects\wendoverds\kirby\config\helpers.php:531
#10 snippet in C:\xampp\htdocs\projects\wendoverds\site\templates\home.php:4
#9 include in C:\xampp\htdocs\projects\wendoverds\kirby\src\Filesystem\F.php:425
#8 Kirby\Filesystem\F:loadIsolated in C:\xampp\htdocs\projects\wendoverds\kirby\src\Filesystem\F.php:364
#7 Kirby\Filesystem\F:Kirby\Filesystem\{closure} in C:\xampp\htdocs\projects\wendoverds\kirby\src\Filesystem\F.php:372
#6 Kirby\Filesystem\F:load in C:\xampp\htdocs\projects\wendoverds\kirby\src\Toolkit\Tpl.php:36
#5 Kirby\Toolkit\Tpl:load in C:\xampp\htdocs\projects\wendoverds\kirby\src\Template\Template.php:163
#4 Kirby\Template\Template:render in C:\xampp\htdocs\projects\wendoverds\site\plugins\minify-html\index.php:18
#3 MinifyHTML:render in C:\xampp\htdocs\projects\wendoverds\kirby\src\Cms\Page.php:1017
#2 Kirby\Cms\Page:render in C:\xampp\htdocs\projects\wendoverds\kirby\src\Cms\App.php:777
#1 Kirby\Cms\App:io in C:\xampp\htdocs\projects\wendoverds\kirby\src\Cms\App.php:1191
#0 Kirby\Cms\App:render in C:\xampp\htdocs\projects\wendoverds\index.php:5
Can anyone identify the problem? Thanks.