Adding code if a region exists?

  • Is there a way I can add code to my Footer layout template which will allow me to add code if a region exists?


    If region 'Slideshow Banner' exists

    Show <Script>My Script</script> to run the banner

    This way my footer code will only contain the JAvascript that particular page requires.

  • If you are using perch_layout to include your footer, you can always pass a variable from the master page, and then check in the footer for the variable.

    In you page template

    1. perch_layout('global/footer', [
    2. 'showScript' => true
    3. ])

    In your footer

    1. <?php if(perch_layout_has('showScript')) : ?>
    2. <script>
    3. // do stuff
    4. </script>
    5. <?php endif;?>