Topic: Embedding JuiceBox into Simple Machines SSI Function [SOLVED]

I've been using Simple Machines Forum software for almost a decade and have been able to use the SSI feature to embed URLs, text, etc., on my website's regular web (PHP) pages so members may access and view text while non-members get a prompt to log in the forums to access the page. I'll admit I only know basic PHP and know I'm not getting the JB gallery embed syntax correct as far as PHP goes and could use an assist. I've taken the code from one of my working pages and made a new page to embed the gallery in. I tested the page and code with text and confirmed my basic code is working. (I'm using a common JBCore folder which is working throughout my site on public viewable galleries)

SMF PHP code embed:

<?php
        $allowed_groups = array(1, 2, 3, 9, 11, 16);
        $can_see = FALSE;
        foreach ($allowed_groups as $allowed)
            if (in_array($allowed, $user_info['groups']))
            {
                $can_see = TRUE;
                break;
            }
            
        if ($can_see)
        {
    echo ' **code goes here to work with logged-in users of SMF**  ';
        }
        
else
        {
            echo ' **Message shown to those not logged into SMF**  ';
        }
        ?>

Below is the working code used elsewhere on my site (example shows generic domain reference for example only). Placing it in the "code goes here" area of the SMF code above results in syntax errors that I don't know enough about PHP to clear.

Juicebox embed code

        <script src="https://www.mydomain.tld/storage/support/jbcore/juicebox.js"></script>
        <script>
            new juicebox({
                baseUrl : 'https://www.mydomain.tld/storage/pictures/galleries/',
                containerId : 'juicebox-container',
                galleryWidth: '100%',
                galleryHeight: '500px',
                backgroundColor: '#222222'
            });
        </script>
        <div id="juicebox-container">
        <noscript>

 <p>You need Javascript to view the gallery on this page.</p></noscript>
        </div>

I'd appreciate any hints. I wanted to try here before I hit up SMF support as sometimes it take a long time to get the answer over there. Thanks in advance.

Re: Embedding JuiceBox into Simple Machines SSI Function [SOLVED]

It looks like you'll need to break out of PHP to enter the gallery's HTML embedding code and open up a new PHP section after the embedding code:
Try replacing:

echo ' **code goes here to work with logged-in users of SMF**  ';

... with:

?>
<script src="https://www.mydomain.tld/storage/support/jbcore/juicebox.js"></script>
<script>
    new juicebox({
        baseUrl: 'https://www.mydomain.tld/storage/pictures/galleries/',
        containerId: 'juicebox-container',
        galleryWidth: '100%',
        galleryHeight: '500px',
        backgroundColor: '#222222'
    });
</script>
<div id="juicebox-container">
    <noscript>
        <p>You need Javascript to view the gallery on this page.</p>
    </noscript>
</div>
<?php

Hopefully this will work for you.

Re: Embedding JuiceBox into Simple Machines SSI Function [SOLVED]

That was golden! Works like a charm.

I appreciate the assist, Steven

Re: Embedding JuiceBox into Simple Machines SSI Function [SOLVED]

You're welcome!
I'm glad it worked. Thank you for letting me know.