PWesterdale / KirbyGram

Instagram Plugin for Kirby CMS
22 stars 3 forks source link

PHP Rendering Error, Breaks Page #25

Closed benaltair closed 3 years ago

benaltair commented 8 years ago

I should start off by saying that I'm definitely novice at PHP.

I put the following code in my footer within a snippet gram.php:

<div class="instagram-feed">
    <? foreach($instagram->feed()->limit(8)->get() as $image): ?>
            <a href="<?= $image->link() ?>" target="_blank" class="insta-item">

                <img src="<?= $image->thumbnail() ?>" alt="<?= $image->caption() ?>">   
            </a>
    <? endforeach; ?>
</div>

When I insert the snippet to footer.php, the page breaks after <div class="instagram-feed"> with nothing else afterwards. I'm running PHP v. 5.4, so that's not a problem right?

Do I need any specific PHP modules added?

It might be worth noting that I'm on shared hosting for this demo. You can see the broken site here: https://new.benaltair.com/

I'll also paste the entire footer.php here:

 <div class="section bg-light no-padding-bottom">

                      <div class="grid">

                            <h2 class="section-title-three align-center"> Stay updated with my newsletter </h2>

                            <form class="form newsletter-form-one" id="mailchimp-form">

                                <div id="subscribe-result">

                                    <div class="sub-success"></div>

                                    <div cLass="sub-error"></div>

                                </div>

                                <div class="form-item">

                                    <input placeholder="Enter Email" class="input-field" type="email" id="Mc-email" required>

                                </div>

                                <div class="form-item">

                                    <button type="submit" name="submit" class="news-subs"> Subscribe </button>

                                </div>

                            </form>

                      </div>

                </div>

                <!-- Newsletter Section Ends -->

            </div>

            <!-- Content Wrapper Ends -->

            <!-- Main Footer -->

            <footer class="main-footer type-one" role="contentinfo">

            <h2 class="section-title-three align-center margin-top-50 padding-bottom-35"> Instagram Feed </h2>

            <!-- Instagram Feed -->

                <?php snippet('gram') ?>

            <!-- Instagram Feed Ends -->

                  <div class="margin-top-50 margin-bottom-40 grid align-center wow fadeInUp">

                       <ul class="social-links align-center">

                            <li> <a href="" class="link"> <i class="icon-social-facebook"></i> </a> </li>

                            <li> <a href="" class="link"> <i class="icon-social-twitter"></i> </a> </li>

                            <li> <a href="" class="link"> <i class="icon-social-dribbble"></i> </a> </li>

                            <li> <a href="" class="link"> <i class="icon-social-tumblr"></i> </a> </li>

                            <li> <a href="" class="link"> <i class="icon-social-youtube"></i> </a> </li>

                       </ul>

                  </div>

                  <div class="contact-detail align-center padding-bottom-90">

                       <p class="intro-text-three"> <img src="<?php echo kirby()->urls()->assets() ?>/img/png/island.png" width="175px" height="73" draggable="false" alt="Vancvouer Island Map Outline" title="Vancouver Island Made"> </p>
                       <p class="intro-text-three"> <a href="mailto:hello@benaltair.com" class="link"> hello@benaltair.com </a> </p>
                       <p class="copyright align-center text small padding-bottom-30"> <?php echo $site->copyright()->kirbytext() ?> <p>

                  </div>

            </footer>

            <!-- Main Footer Ends -->

        </div>

        <!--Main Content Ends-->

    </div>
    </div>
    </div>

    <!--Main Container ends-->

    <!--Javascipts-->

    <script type="text/javascript" src="<?php echo kirby()->urls()->assets() ?>/js/jquery.js"></script>
    <script type="text/javascript" src="<?php echo kirby()->urls()->assets() ?>/js/jquery.isotope.js"></script>
    <script type="text/javascript" src="<?php echo kirby()->urls()->assets() ?>/js/imagesloaded.js"></script>
    <script type="text/javascript" src="<?php echo kirby()->urls()->assets() ?>/js/owl.carousel.js"></script>
    <script type="text/javascript" src="<?php echo kirby()->urls()->assets() ?>/js/tatva.js"></script>
    <script type="text/javascript" src="<?php echo kirby()->urls()->assets() ?>/js/fotorama.js"></script>
    <script type="text/javascript" src="<?php echo kirby()->urls()->assets() ?>/js/jquery.fullPage.js"></script>
    <script type="text/javascript" src="<?php echo kirby()->urls()->assets() ?>/js/waypoints.min.js"></script>
    <script type="text/javascript" src="<?php echo kirby()->urls()->assets() ?>/js/jquery.counterup.min.js"></script>
    <script type="text/javascript" src="<?php echo kirby()->urls()->assets() ?>/js/jquery.sidr.min.js"></script>
    <script type="text/javascript" src="<?php echo kirby()->urls()->assets() ?>/js/jquery.ajaxchimp.js"></script>
    <script type="text/javascript" src="<?php echo kirby()->urls()->assets() ?>/js/jquery.magnific-popup.js"></script>
    <script type="text/javascript" src="<?php echo kirby()->urls()->assets() ?>/js/lity.min.js"></script>

    <!--Javascripts End-->

  </body>

</html>
steadweb commented 8 years ago

Hi @benaltair

Can I assume you removed it from that page because it seems to render ok (apart from there's no reference the plugin).

Any chance you could provide error logs as well? I have a suspicion that shorthand PHP tags aren't enabled. If you're using shared hosting, you may not have the ability to turn this on. If the issue relates to shorthand tags I'd suggest using the following piece of code instead:

<div class="instagram-feed">
    <?php foreach($instagram->feed()->limit(8)->get() as $image): ?>
            <a href="<?php print $image->link() ?>" target="_blank" class="insta-item">

                <img src="<?php print $image->thumbnail() ?>" alt="<?php print $image->caption() ?>">   
            </a>
    <?php endforeach; ?>
</div>