Structure field & Kirby 2.3.0

Hi there,
after updating a website to Kirby 2.3.0 i am encountering a strange message, that i don’t understand:

Warning: file_exists() expects parameter 1 to be a valid path, array given in /…/kirby/toolkit/lib/tpl.php on line 19

I am using the structured field to display some sort of structured homepage with bits from various parts of the website…
this worked normally under 2.2.0 but seems to encounter a problem with the templating bit calles tpl.php…

as i am not familiar with the new components structure i am slightly lost with this message…

does anyone have an idea what might be the problem?
as always many thanks in advance

matthias

That looks like a bug to me.

Could you please post the code you are using to output the structure field (e.g. the snippet you use)?

Sure. Thanks for answering.

I am using the kirby-builder plugin (https://github.com/TimOetting/kirby-builder)
This is the part in the template:

<?php foreach($page->builder()->toStructure() as $section): ?>
   <?php snippet( snippet('sections/'.$section->_fieldset(), array('section' => $section)) ) ?>
<?php endforeach ?>`

This points to either snippets/sections/frontmenu.php or snippets/sections/frontprojects.php

This is frontmenu.php:

<?php $frontmenu = $pages->find($section->frontmenu()) ?>
<a href="<?php echo $frontmenu->url() ?>">
	<div class="part frontmenu">
		<h2><?php echo $frontmenu->title() ?></h2>
	</div>
</a>

and this frontprojects.php:

<?php 
	$frontproject = $pages->find($section->frontprojects());
	$image = $frontproject->images()->sortBy('sort', 'asc')->first();
	$bg = thumb($image, array('width' => 600, 'upscale' => true, 'quality' => 80))->url(); 
?>
<a href="<?php echo $frontproject->url() ?>">
	<div class="part frontproject <?php echo $section->size() ?>" style="background-image: url('<?php echo $bg ?>'); background-size: cover">
		<h2><?php echo $frontproject->title() ?></h2>
	</div>
</a>

It seems both of these cause the message, so i guess the problem is in the way they are called. By the way, the results of these snippets are there as well, which means that they work and deliver the results. The messages appear to be a warning but they don’t prevent the whole thing from working…

You are using two nested calls of snippet, that’s not going to work and doesn’t really make sense. The following should work:

<?php snippet('sections/'.$section->_fieldset(), array('section' => $section)) ?>

That’s in fact an error in the plugin docs, I have created an issue.

1 Like

Wow. Thanks again for helping out.
I can’t really get my head around some of these things…

Matthias