9

I'm upgrading a site I created 2 years ago from D6 to D7. In that site, I have a view of items that are grouped according to year, so that the items for each year show up on a separate page -- you pass the view the year, and it displays the appropriate nodes for that year. I need to have "previous year" and "next year" links, which would link to pages that show the nodes for the previous or next years, as appropriate.

I did this in the old (D6) site by allowing the header to display PHP code (using the PHP filter), doing math on the passed-in "year" parameter, and writing out the link to the next and previous years as raw HTML. This feels wrong - very un-Drupal — but I can't figure out how to get views to do it more natively.

My feeling is that I'd like to use something like the grouping field (from "Format/Settings") except that instead of just putting a heading between the grouped nodes (which in my case would result in a page with over a thousand nodes displayed) it would split them into pages based on that grouping field.

Any ideas?

I found some items that point to a possible answer. There's this previous question:

Views pagination based on taxonomy terms

My years ARE also taxonomy terms, so this would work for me if the question was ever answered as asked. While there is no actual answer, there is a pointer to this very nice Earl Miles article:

http://drupalwatchdog.com/1/1/how-to-create-new-features-in-views-3

That is VERY close to my use case, and I guess if I have to I can try to create a Views Plugin based on Earl's instructions, but I'm hoping for something simpler. I'd rather use a plugin than write one!

(In the article, Earl says the code for the plugin could be found at http://drupal.org/project/views_plugin_examples, but when I go to that project it appears to be empty.)

In any case, this looks like a "solved problem" -- but I can't find the solution! Any pointers, before I re-invent the wheel?

  • Update: I was able to find get the code for the "views_pager_month" module that Earl describes in his article by going to the "Version control" tab of the project and following the instructions to pull it down with git. I'll see how close it comes to satisfying my needs. But...I don't want to discourage anybody from making suggestions! – cellear Mar 13 '13 at 22:00
  • And, have you made a nice module out of it or so? ;) – Turion Aug 4 '13 at 17:59
1

Download the Date module at and be sure to active its Date Views submodule. That will add a Page by date option to the pagers listed in your Views config page. Here is a nice writeup by Richard Schulte on how to configure the date pager.

0

The easy way: use views summaries. You can put it as an attachment, right after your main view, and theme it as a pager.

  • Unfortunately the link is broken. Can you somehow rephrase what it contained? – leymannx Nov 14 '16 at 14:37
  • @leymannx fixed the link. I'm ok with expanding the answer, edits are welcome. – Capi Etheriel Nov 25 '16 at 18:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.