Howdy!
Trying to split my code while it keeps growing and thought I was doing almost exactly what this example is doing
https://getkirby.com/docs/templates/snippets
The Template
$items = page('home’)
->children()
->visible()
->filterBy(‘tag’, 'services', ',');
?>
<?php foreach ($items as $item): ?>
<?php if ($item->share() != '1'): ?>
<?php snippet(’share-component’, array(‘share-component’ => $item)) ?>
<?php else: ?>
…something else
<?php endif ?>
<?php endforeach ?>
The Snippet (share-component)
<a href="http://www.facebook.com/sharer.php?u=<?=rawurlencode($item->url());?>" target="blank" title="Share on Facebook"
…svg icon
</a>
Unfortunately this gives me error message that says the variable ($item) is undefined.
Could someone kindly tell me what I’m doing wrong here?