Print/Echo dynamic content in JavaScript (Galleria)

53 Views Asked by At

Thanks for taking the time to read my question. I have a little problem I'm bumping in to. I can't seem to figure it out on my own. I hope you could help me.

On my website I have a dynamic field that is filed from the back-end with a code, like 72157629341113913. On each page this code is different. But I also have Galleria with the flickr plugin running on the page which needs a set ID (in this case: 72157629341113913) to run. The Galleria code to make this work looks like this:

Galleria.run('.galleria', {
    flickr: 'set:72157629341113913',
    flickrOptions: {
        sort: 'date-posted-asc',
        thumbSize: 'medium'
    }
});

On every page the set ID is different. So I would like to have something like:

Galleria.run('.galleria', {
    flickr: 'set:$image_id',
    flickrOptions: {
        sort: 'date-posted-asc',
        thumbSize: 'medium'
    }
});

But I don't know how to get it to work. I have this on my page:

<?php $image_id = get_row('image_set_id'); ?>
<?php echo $image_id; ?>

This echo's the ID but when I use this $image_id this doesn't get the ID in the Galleria code. Any help would be really helpful and thanks in advance. I think that combining Java and PHP isn't really the way to go? I guess? Thanks again for your time reading my question. I hope it's clear what I'm trying to do.

1

There are 1 best solutions below

6
Scaramouche On

Practically all PHP coding I have ever done has been via a framework, so raw PHP coding in html file is not my strong, please try the following:

Galleria.run('.galleria', {
    flickr: 'set:' + <?php echo $image_id; ?>,
    flickrOptions: {
        sort: 'date-posted-asc'
    }
});

HIH