Paging lists of content items

Topics: Customizing Orchard, General
Nov 23, 2011 at 1:55 PM

I need to paginate through a series of Artist pages. (So when viewing Artist #1, pagination links take the user to previous/next Artist in the series). Each Artist has associated ArtWork that would display (in summary) on the Artist page. These ArtWork items _do not_ need to paginate on the Artist page but when you click on each one, the user is taken to the ArtWork detail page.

I first tried to implement this with a container/containable relationship (Artwork child of Artist). And I even build an ArtistList container (so ArtistList has Artists, each Artists has ArtWork). Then I attempted to use the taxonomies module so that on the ArtWork detail page, I could link back to the associated Artist. Neither of my implementations give me the results I need.

What I can’t figure out is pagination. I need to paginate through the Artist content items themselves (not paginate through ArtWork while on Artist page--which is what currently happens when I use container/containable). On each Artist page, the Artwork items are listed (in summary). When I click the "next", I don't want to paginate through the Artwork items, I need it to go to the next Artist in the series.

I realize I might have to customize Pager (similar to TheAdmin) to get the pagination to render how I want (like here: I think I can handle that. Right now the problem is I can’t even get pagination to show up at all for Artists.

Can anyone get me started on a way to do this?
Thanks so much for any guidance.

(using Orchard 1.3.9)
Nov 23, 2011 at 3:14 PM

It looks like you want to have a navigation (previous-next between items) similar to what the Chapters module has. Try it, it might solve the problem altogether, if not, you'll get some ideas for a new module start.

Nov 23, 2011 at 7:10 PM
Edited Nov 23, 2011 at 7:57 PM

Thanks so much for pointing me to Chapters. I did a quick hello world proof-of-concept and it looks like it might work. 

I created a Book call "Artists" and each chapter in the book is an Artist. I created a few chapters under Artist called ArtWork. So the parent/child relationship seems to work as I need it to (again, THANKS!) :-) I'm encouraged.

What I'm unsure about is if I can also have an ArtWork content item serve as a containable within Artist (container) in order to be able to render more info about the ArtWork (an image thumb and a title) than just the navigation link. With Chapters, all that renders about the "child" chapter is a link to it in the table of contents. This is good. The botton next/previous/up nav solves my pagination problem. But I need to render a kind of summary view of the ArtWork items while on the Artist page (not just a link to those chapters). I know I can do that using container/containable.

Nov 23, 2011 at 10:58 PM

I'm glad I could help!

Take a look at how the module renders the list. As far as I can remember the chapter list there is one shape (the list items are not individual ones), so you'll have to override it and create a list that also has a summary included. Use the Shape Tracing module to determine which shape to override. However depending on what data the driver gives the view, a simple shape override might not be sufficient... If this is the case, you have to stick to native containers and create an own part that displays the previous-next links (this should be a quite simple task).

Nov 23, 2011 at 11:30 PM

Quick note, for each Book, there is a chapter content type which is created. You can add fields and parts to it, so it's configurable per each chapter, and displayed with it too.

Nov 24, 2011 at 10:49 AM

Yes, but in the chapter list are the items also displayed with their corresponding parts (would be Summary I think) or just their title?

Nov 24, 2011 at 6:01 PM

I set up 2 Books (Artists, Artwork). Each chapter in the Artists Book is an individual artist biography. Each chapter in the Artwork book contains all the content for an individual piece of art. I was able to make an Artwork Chapter containable and an Artist Chapter a container (as sebastien suggested). So the parent/child relationship using native container allowed me to render a list of Artwork (as summary) for each Artist. I can then paginate through the Artists, or if I'm viewing an individual Artwork, I can also paginate through the Artwork items (since Artists and Artwork are two separate Books).

Beautiful. On the front-end, it works exactly as I need it to.

However, I'm now seeing that when adding Artists/Artwork Chapters, my content editors might have some trouble with sort order/position. I see that I can specify the Position field (numerically). Ideally, I'd like to not have to manually sort the Chapters by this Position field. The question then is: what do you sort by? :-)

Here's the problematic use case:  a bunch of artists and artwork have already been entered w/ Position controlling the sort order. I have ~75 artists. We add a new one (a new Chapter to the Book) in the middle (or worse, toward the beginning). I now have to go back through and update the Position field of all the Chapters that come after the newly entered one. Is that correct? I could also specify a decimal value for Position to squeeze it in there, but I hesitate to have my non-technical users have to keep track of this. My users really just want the Artist list to be in alphabetical order. So I'd love a way to either a) sort by Title, b) provide a custom field on the Chapter that I could sort on (if I did this, I would just enter the surname of the artist).

Hope that makes sense. Thanks so much for the help guys. This Chapters module combined with Container/Containable is working out.


Nov 24, 2011 at 6:28 PM

I guess there aren't other options for positioning, then (but maybe ask Sebastien whether such functionality will ever be implemented).

Standard container-containables have these type of sorting (alphabetical), so if this is absolutely necessary maybe you should go back to writing a small module for the next-previous links? BTW it dawned on me that even for that there is a module. If that doesn't suite your needs totally, then either contact the author to request features or take the module as a start and implement your own.

Nov 24, 2011 at 6:37 PM

I think this should not be so hard to provide this choice ... At the Book level then, so you could even choose it based on each Artist. 

A quick note, you can define positions by steps of 100, so you can insert them in the middle without modifying the positions of others.