# Pagination with Flickr.rb

**URL:** <https://www.ruby-forum.com/t/pagination-with-flickr-rb/75679>\
**Category:** Rails\
**Created:** [November 12, 2006, 10:08am UTC](https://www.ruby-forum.com/t/pagination-with-flickr-rb/75679 "2006-11-12T10:08:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jonathan\_Barket](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/db5fbb/32.png) [@Jonathan\_Barket](https://www.ruby-forum.com/u/Jonathan_Barket)\
**Post date:** [November 12, 2006, 10:08am UTC](https://www.ruby-forum.com/t/pagination-with-flickr-rb/75679/1 "2006-11-12T10:08:23Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Jonathan\_Barket](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/db5fbb/32.png) [@Jonathan\_Barket](https://www.ruby-forum.com/u/Jonathan_Barket)\
**Post date:** [November 12, 2006, 6:35pm UTC](https://www.ruby-forum.com/t/pagination-with-flickr-rb/75679/2 "2006-11-12T18:35:39Z")

</div>

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:

> **[Flickr Services: Flickr API: flickr.photos.getRecent](https://www.flickr.com/services/api/flickr.photos.getRecent.html)**
>
> The safest and most inclusive global community of photography enthusiasts. The best place for inspiration, connection, and sharing!

Hope that helps.

Dougal.

---

<div class="post-metadata">

**Author:** ![Jonathan\_Barket](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/db5fbb/32.png) [@Jonathan\_Barket](https://www.ruby-forum.com/u/Jonathan_Barket)\
**Post date:** [November 13, 2006, 5:51pm UTC](https://www.ruby-forum.com/t/pagination-with-flickr-rb/75679/3 "2006-11-13T17:51:29Z")

</div>

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.
