Return error when get checkboxes in the page

panelfield

#1

Now I use kirby 2.5.5
I create a checkboxes at the page blueprints and type is images.
But I get in the page error.

In page’s template, If echo $page->field-checkboxes-name()
it can print sample-1.jpg, sample-2.jpg…
but echo $page->field-checkboxes-name()->split(’,’)
then…return error :frowning:


#2

Which error?

I think it has to do with echoing an array?


#3

@bvdputte is right. The split() method returns an array, so you have to loop through it to print it out:

$images = $page->checkbox_field()->split(','); 
foreach($images as $image) {
  echo $image;
}

#4

Thanks all. Now I can print out images, but I can not use crop(), I want make a thumb for image, Why?

$images = $page->checkbox_field()->split(’,’);
foreach($images as $image_name) {
$image = ’ (img src="’.$page->contentURL().’/’.$image_name.’" alt="")’;
echo $image;
}


#5
$images = $page->checkbox_field()->split(','); 
foreach($images as $image):
  if($img = $page->image($image)) {
 echo $img->crop(400);
}

#6

Cool! Thank you texnixe!