0

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.

Calvin Nunes
  • 6,376
  • 4
  • 20
  • 48
Jay-oh
  • 426
  • 2
  • 6
  • 28

1 Answers1

1

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

Scaramouche
  • 3,188
  • 2
  • 20
  • 46
  • Thanks for you answer but I get the error: `Uncaught SyntaxError: Unexpected token ,`. I've tried it without the echo but still no go... – Jay-oh Apr 18 '18 at 13:58
  • @Jay-oh maybe it is because I copied your code and added the change, I see now there is a missing `}` at the end, could that be the problem? edited – Scaramouche Apr 18 '18 at 14:02
  • My bad. I copied the correct code syntax. Could you have a look at it again? – Jay-oh Apr 18 '18 at 14:05
  • @Jay-oh, well I just fixed it in my answer, could you try it again? if the error persists, could you post what `` is outputting? – Scaramouche Apr 18 '18 at 14:07
  • $image_id outputs `72157629341113913` which is the image set id I need... – Jay-oh Apr 18 '18 at 14:30
  • @Jay-oh if that is the case then I don't see how `flickr: 'set:' + ` is not working – Scaramouche Apr 18 '18 at 14:42