Passing multiples variables to snippet not working

When calling a snippet with snippet('post', array('entry' => $entry->id(), 'foo' => "bar")); $entry is defined but $foo is not. Any ideas why?

2 Likes

What is your Kirby version? It that your real example you tested with?

3.4.4 and yes

Hm, that doesn’t make sense. Could you post the snippet please?

<?php
$video = $pages->find($entry);
echo $foo;
?>
<a class="video-thumb" href="<?= $video->url(); ?>">
<?php if($image = $video->thumbnail()->toFile()): ?>
<img src="<?= $image->url() ?>" srcset="<?= $image->srcset() ?>" class="video-thumb__image" alt="<?= $image->alt() ?>">
<?php endif ?>
<h3 class="video-thumb__title"><?= (($video->short()->isNotEmpty()) ? $video->short() : $video->title()) ?></h3>
</a>

That’s the current state.

As I said, really weird and of course, I cannot reproduce this in a Starterkit.

What if you move your variables in the snippet the other way round, first foo, then entry? And how is $entry define in the template?

The other way it’s still foo that’s not working 🤷

Can you reproduce the issue in a fresh Starterkit?

Do you use any plugins, custom code?

Unfortunately it works in a fresh install. Yes to plugins and custom code. This won’t be fun. :frowning:

Feel free to send me a copy of the project if it is under no NDA.

1 Like

I’ll give it a try and if I can’t figure it out, I’ll come back to you.

Have you found this issue?

Since you are seemingly experiencing the same issue, please provide the following information:

  • Kirby version
  • PHP version
  • List of all plugins you are using with their version numbers
  • other custom code (what sort of)
  • your code example