Pagination with Flickr.rb

Hey guys,

I hate to ask a ridiculous question, but for the life of me I can’t
figure this out. I followed the flickr.rb screencast, and now I’m trying
to modify it, but I can’t figure out how to paginate photos.

In other words, I want it to only display 10 photos (:per_page => ‘10’),
but then I want to be able to page back and forth to see the rest.

Anyone done anything similar? I’ve been looking for quite some time now.

Jonathan Barket wrote:

In other words, I want it to only display 10 photos (:per_page => ‘10’),
but then I want to be able to page back and forth to see the rest.

Hey Jonathan,

This is something I had thought of doing, but hadn’t looked into just
now. You can specify which page you want by using :page => ‘x’ symbol.
I’ve not tried this, but it should work according to the Flickr API
docs.

The API docs for flickr.rb aren’t the best, but more detail on the
methods and their arguments can be found in the flickr API docs
themselves. Here’s the relevant page for your query:

http://www.flickr.com/services/api/flickr.photos.getRecent.html

Hope that helps.

Dougal.

On Nov 12, 2006, at 17:08 , Jonathan Barket wrote:

I hate to ask a ridiculous question, but for the life of me I can’t
figure this out. I followed the flickr.rb screencast, and now I’m
trying
to modify it, but I can’t figure out how to paginate photos.
In other words, I want it to only display 10 photos (:per_page =>
‘10’),
but then I want to be able to page back and forth to see the rest.
Anyone done anything similar? I’ve been looking for quite some time
now.

If you take a look at flickr.rb, you’ll find its photos method simply
collects the photo ids returned by the Flickr method
flickr.photos.search.

That Flickr method actually provides you with the total number of
matched items, but this information is not used by flickr.rb. You
may want to modify the photos method a bit so that it returns
that number (and perhaps other pagination info too, along with the
photos). Then just as Dogulas Shearer has said, you can go back and
forth using the page parameter.

d.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs