All fields in array?

how can I output all fields of an page in an array?
I found pluck(). But this is not exactly what I want. I want all from one item and not one field from all items.


$c = $page->content();
foreach ($c as $key => $value) {
  if ($key == "fields") {
    foreach ($value as $field) {
      echo $field . ": " . $page->$field() . "<br/>";

originally copied from this post, not tested


thanks for it!
As first I tested the output from $page->content(); but there I got the error β€žCatchable fatal error: Object of class Content could not be converted to string inβ€¦β€œ. Whats going wrong here?
Here is my code:

<?php foreach($page->children() as $section): ?>
<section class="text list">
	<?php foreach($section->children() as $book): ?>
	<article class="list-item">
	<div><?php echo $book->content(); ?></div>
		<?php if($book->hasImages()) : ?>

$book->content() returns an object, you cannot echo that …

1 Like

your posted code works perfekt for me. Thanks!

You can get an array of the whole page array with


or the whole page object (also including e.g. uid, slug, intendedTemplate) with

1 Like