0

I have a page view in a Drupal 7 view with contextual filters in the URL. something like /events/%1/%2 - the first parameter is the year, the second is a taxonomy term. So /events/2014/3 is all the events in 2014 in category 3.

I want to provide next and previous links based on the year (the first filter parameter). Is this even possible?

  • Like next and previous year? – Kari Kääriäinen Feb 7 '14 at 21:10
  • Yes, a next year and previous year. Ideally they'd be in the view header, but that's not necessary. – Michael Feb 7 '14 at 21:12
3

Not sure what your strengths are, but you could easily accomplish this with a custom php block. If you did something along the lines of

<?php
$previous = arg(2) - 1;
$next = arg(2) + 1;
?>
<a href="/events/<?php print $previous . '/' . arg(3)?>/">Previous</a> 
<a href="/events/<?php print $next . '/' . arg(3)?>/">Next</a> 

I would clean up that code and use the l() function to create a link, but that is the general concept.

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.