I'm really new to Kirby and PHP and I try to use 2 variables in a Snippet. This is my Code right now
<div class="container">
<h2><?= $variable1 ?></h2>
<?php
foreach (page('blogs')
->children()
->listed()
->filterBy('tags', 'variable2', ',')
->flip() as $subpage) :
snippet('blogkarte', ['subpage' => $subpage]);
?>
<?php endforeach ?>
I understand how to use the $title method for Variable1, but it don't work with Variable2
<?php snippet('blogkarten', ['variable1' => 'MYTEXT"', 'variable2' => "MYTEXT"]) ?>
This is the way I tried, but it didn't worked...
I hope somebody can help me
Right now, the second parameter of your
filterBy()method is a hard-coded string literal: PHP is not seeing is as a 'variable named $variable2', but rather as the literal string "variable2".If you're correctly passing a variable named
$variable2to your snippet, and you want to use it as the second parameter in yourfilterBy()method, you just need to do this: