Trouble starting out with plug-ins, specifically KirbyGram

Howdy folks,

I am testing the waters with a local installation of Kirby running on MAMP in OS X. I have successfully granted permission and installed KirbyGram within mysite.com/site/plugins/kirbygram. My Instagram feed appears when I visit mysite.com/kirbygram/done, although when I use the same code within a template the HTML output breaks.

    <h2>Feed</h2>
    <ul>
        <? foreach($instagram->feed()->limit(5)->get() as $image): ?>
        <li>
            <img src="<?= $image->thumbnail() ?>" />
        </li>
        <? endforeach; ?>
    </ul>

It seems within the template Kirby does not recognize $instagram. I checked to see if this is case sensitive, although this does not seem to be the issue. Any pointers? I feel as though I am overlooking something incredibly simple.

Thank you.

Hey,

try this:

<h2>Feed</h2>
<?php $instagram = new Instagram(); ?>
<ul>
	<?php foreach($instagram->feed()->limit(5)->get() as $image): ?>
	<li>
		<img src="<?php echo $image->thumbnail() ?>"  />
	</li>
	<?php endforeach ?>
</ul>
2 Likes

Thank you very much. That worked. Now I recognize that I needed to establish $instagram with…

<?php $instagram = new Instagram(); ?>

Thanks again!

1 Like

Author here, apologies I must update the documentation to demonstrate this.
Sorry for giving you a rough start with Kirby!

1 Like

Please do. I just had the same problem. Lucky for me, this thread already existed. :smile: