toStructure() throws TypeError

Hello there,
at the moment I’m trying to work with a huge file for an upcoming project (which I mentioned here).

I downloaded some MySQL tables as a yaml, pretty straight forward I created a blueprint for the site and all the positions are listet in my panel. Seems to work just fine. But when I try to work with my tables, I get an error every time.

My code looks like this:

<div>
  <?php foreach ($page->namenstage()->toStructure() as $namenstag): ?>
    <p>
      <?= $namenstag->title() ?>
    </p>
  <?php endforeach ?>
</div>

My text file for the site looks like this:

title: Namenstage
----
namenstage:
-
  uid: 630
  pid: 199
  tstamp: 1245734548
  crdate: 1199649269
  cruser_id: 1
  deleted: 0
  hidden: 0
  category: 12
  begin: 1214172000
  end: 0
  location: ""
  organiser: ""
  email: ""
  title: "Edeltraud"
  teaser: "\"die traute Freundin\""
  description: "<P><STRONG>23. Juni Edeltraud  (Edeltraut) </STRONG></P>\r\n<P><U><STRONG>Persönliche Daten:</STRONG> </U></P>\r\n<P>Gemahlin von König Egfrieds von Northumberland, später Nonne, ( † 679in Ely/England) </P>\r\n<P>Edeltraud (Etheldred), die Tochter des Königs von Ostanglien, wurde schon in sehr jungen Jahren mit einem schottischen Prinzen verheiratet. Nach dessen frühem Tod wurde die Witwe - sie war etwa 25 bis 30 Jahre alt - aus politischen Gründen gegen ihren Willen mit dem 15-jährigen König Egfried von Northumbrien vermählt, stellte aber die Bedingung, dass die Ehe nicht vollzogen werden dürfe. Als sich der junge Gemahl dann aber nicht an das Versprechen halten wollte, floh die Königin in das Kloster Coldingham. Auf der Insel Ely in Essex, wo sie nach dem Tode ihres ersten Gatten einige Zeit gelebt hatte, gründete sie, nachdem ihr zweiter Gemahl eine andere geheiratet und sie freigegeben hatte, ein Doppelkloster, das später große Berühmtheit erlangen sollte. + 23.6.679 </P>\r\n<P><U><STRONG>Wird dargestellt:</STRONG> </U></P>\r\n<P>Die heilige Edeltraut wird dargestellt als königliche Nonne mit Jesuskind, Buch und knospenden Stab, Quelle zu Füßen, mit fliehendem Teufel. </P>\r\n<P><STRONG><U>Patron: </U></STRONG></P>\r\n<P>Edeltraud ist Patronin gegen Augenleiden(nach anderen gegen Halsleiden). </P>"
  link: ""
  image: "etheldreda.jpg"
  directlink: ""
  starttime: 0
  endtime: 0
  fe_user: 0
  event_type: 4
  exc_event: ""
  exc_group: ""
  rec_end_date: 2145826800
  rec_time_x: 0
  rec_daily_type: 0
  repeat_days: 1
  rec_weekly_type: 0
  repeat_weeks: 1
  repeat_week_monday: 0
  repeat_week_tuesday: 0
  repeat_week_wednesday: 0
  repeat_week_thursday: 0
  repeat_week_friday: 0
  repeat_week_saturday: 0
  repeat_week_sunday: 0
  rec_monthly_type: 0
  repeat_months: 1
  rec_yearly_type: 0
  repeat_years: 1
  repeat_year_month: 0
  repeat_year_day: 0
  location_id: 0
  organizer_id: 0
  organizer_feuser: 0
-

And the error is the following:

Argument 1 passed to Kirby\Cms\StructureObject::setContent() must be of the type array or null, string given, called in /Applications/MAMP/htdocs/chav_sandbox/kirby/src/Toolkit/Properties.php on line 130

I also tried to run the code in another Kirby installation but it’s also not working. Any tips?

After some more tries: Is there a possibility that a file is too long?
I mean, it has over 800 structure field entries… :sweat_smile:

I think the problem is rather that last dash at the end of the file.

But I wouldn’t create these as structure fields, that might be difficult to handle in the Panel with so many entries?

Either pages or put it into a CSV or spreadsheet. You can then make this editable in the Panel, if need be.

Indeed, it was this little dash! Thanks!

Hmm, I think a structure field works best here. Since the entries do not need to be changed in any time. I can work quite good with the fields so far :slight_smile: