# How to paginate or organize Expression Engine by custom field data input

I have an ExpressionEngine site that takes information entered from an admin, and information entered from users through SafeCracker, and displays that information in a timeline format.

The information that is entered has a custom field called {story_year}. We use that field to sort the entries based on the entered date. This means that users can specify a date, as well as admins.

Because showing hundreds of entries at once takes a long time load, we've introduced pagination. But that pagination breaks it up arbitrarily by amount.

Is there a way to paginate by {story_year}? Possibly conditionals like:

{if story_year >= "2010" }
{page}
<li><a href="{pagination_url}" class="{if current_page}active{/if}">&bull;</a></li>
{/page}
{if:elseif story_year >= "2000"}
{page}
<li><a href="{pagination_url}" class="{if current_page}active{/if}">&bull;</a></li>
{/page}
{/if}


Relevant URLs are here: http://thinkx.net/clients/manship/index.php/timeline - the ultimate display of the timeline. http://thinkx.net/clients/manship/index.php/Timeline/add - the field entries we sort by.

There isn't a way to do this with native pagination.

Take a look at the YearList addon to see if you can get something working with that.

Fetches the distinct years of all entries in a specified weblog. Can be used to create a year archive list.

The Year Listing plugin is a simple way to get a distinct 4 digit year for your entries. This way you can list out years for archives.

{exp:yearlist channel="yourchannel" category="1"}
{year} {/exp:yearlist}

That will return an array of years. Use {year} to print them to the screen and wrap in any markup needed. There are currently no linebreaks or HTML associated with this plugin.

You can pull the year from the URL and use it with your entries tag to pull entries for just that year.

You'll need to make sure your entry date year matches your custom field year or you can try hacking this addon to pull from your custom field instead of the entry date field.

• If I'm reading that correctly, you're saying I can use {story_year} instead of {year}? I'll look into that. Thanks! – thatgibbyguy Mar 6 '13 at 14:27
• No, I'm saying if your entry date matches your story_year field, you can use {year}. Or you can look at the code for this addon and perhaps adjust to meet your needs. – Anna_MediaGirl Mar 6 '13 at 16:29
• Got it. I don't think there's a way to do what I'm asking without writing something custom. What we're trying to do is simplify manship100.com/timeline to speed it up. It looks like optimization is our answer, which is another thing I don't know much about heh. Thanks for your help! – thatgibbyguy Mar 6 '13 at 16:35
• Try this... JS for pagination and CE Cache using the static driver for caching. The page will be insanely fast. – Anna_MediaGirl Mar 6 '13 at 17:06
• I'm actually attempting to implement infinite scroll right now. It still isn't working but it's close. But pagination is working great! Super fast now. – thatgibbyguy Mar 14 '13 at 16:29