I've no idea if anyone here can help with this but I thought I'd ask anyway. So basically my skills stretch to HTML/CSS, I'm no programmer. I can work with JS/PHP etc but I can't write it myself. With the help of someone who does know that stuff I managed to get a database driven website nearly finished. However now because of other stuff he doesn't have the time to really help, so I'm in lumber with this last part.
So basically I want to display photos from flickr based on their tag. I looked it up and found out how to do it, via the API, so I got my API key, worked out the code I needed to generate the data and so on. Didn't take long to get it working in basic format.
The issue I have is the tags, I need to define them dynamically, based on the page you're on. If I just write in a static tag on my database page or the JS file obviously every page will display the same photos.
Essentially what I want is like they have here, if you click on a show with photos listed - http://downloads.linkinpark.com/store/container.aspx?year=2011
(They use the public feed limited to 20 photos though, I wanted more so needed the API)
So you can see they dynamically create/display the tag (eg #LPLIVE-06-09-2012) on the page and show flickr photos with that tag. I can't see how they do it though, with my limited knowledge on this side of things.
This is also something similar - http://carst.me/2011/08/search-for-photos-using-jquery-flickr-api-and-fancybox-part-2/
Although with that they use the search term as a 'dynamic' tag.
I can generate the tag I need with PHP and echo it on each page like they do above but how do I get that dynamically into the javascript which is generating and displaying the photos? Or is that impossible, since I know PHP is server side and JS is client side?
My JS at the moment is:
So, if that made sense to anyone perhaps someone has an idea of what I need to do?
So basically I want to display photos from flickr based on their tag. I looked it up and found out how to do it, via the API, so I got my API key, worked out the code I needed to generate the data and so on. Didn't take long to get it working in basic format.
The issue I have is the tags, I need to define them dynamically, based on the page you're on. If I just write in a static tag on my database page or the JS file obviously every page will display the same photos.
Essentially what I want is like they have here, if you click on a show with photos listed - http://downloads.linkinpark.com/store/container.aspx?year=2011
(They use the public feed limited to 20 photos though, I wanted more so needed the API)
So you can see they dynamically create/display the tag (eg #LPLIVE-06-09-2012) on the page and show flickr photos with that tag. I can't see how they do it though, with my limited knowledge on this side of things.
This is also something similar - http://carst.me/2011/08/search-for-photos-using-jquery-flickr-api-and-fancybox-part-2/
Although with that they use the search term as a 'dynamic' tag.
I can generate the tag I need with PHP and echo it on each page like they do above but how do I get that dynamically into the javascript which is generating and displaying the photos? Or is that impossible, since I know PHP is server side and JS is client side?
My JS at the moment is:
Code:
$(function() {
var apiKey = 'MY_API_KEY_IS_HERE';
var tag = 'THE TAG I NEED TO DYNAMICALLY GENERATE';
var perPage = '25';
var showOnPage = '6';
$.getJSON('http://api.flickr.com/services/rest/?format=json&method='+
'flickr.photos.search&api_key=' + apiKey +
'&tags=' + tag + '&per_page=' + perPage + '&jsoncallback=?',
function(data){
var classShown = 'class="lightbox"';
var classHidden = 'class="lightbox hidden"';
$.each(data.photos.photo, function(i, rPhoto){
var basePhotoURL = 'http://farm' + rPhoto.farm + '.static.flickr.com/'
+ rPhoto.server + '/' + rPhoto.id + '_' + rPhoto.secret;
var thumbPhotoURL = basePhotoURL + '_s.jpg';
var mediumPhotoURL = basePhotoURL + '.jpg';
var photoStringStart = '<a ';
var photoStringEnd = 'title="' + rPhoto.title + '" href="'+
mediumPhotoURL +'"><img src="' + thumbPhotoURL + '" alt="' +
rPhoto.title + '"/></a>;'
var photoString = (i < showOnPage) ?
photoStringStart + classShown + photoStringEnd :
photoStringStart + classHidden + photoStringEnd;
$(photoString).appendTo("#flickr");
});
$("a.lightbox").lightBox();
});
});
So, if that made sense to anyone perhaps someone has an idea of what I need to do?