Not a week goes by where I'm not trying to solve some issue that a particular site needs. In this case it was the need for a <<Previous Next>> pager between nodes that are linked to from a View.
I explain....
This site had already had nice Galleria galleries showcasing projects and a simple View to show them all in a listing. The problem was that when viewing the node, I wanted to have a pager somewhere on the screen to allow a user to page between those project nodes.
My first attempt was to build another View of single nodes of the project type with a mini-pager that I would position with css where ever I wanted. The view was set to display one item per page. Then, from the main listings view, rather than link the titles and thumbnails to the nodes themselves I rewrote the link output. On each listing, the links to the node were rewritten to go to the path of the single node view. So the links looked something like this:
/singlenode_view?page=[counter]
The counter was a Global: View result counter token replacement. So when a user clicked on that projects title or thumbnail, it loaded the single node view on the page that corresponded to that node. Sweet! And using ajax on the view allowed the page load to be ajaxy. Sweeter!
Now when someone follows a link from the listings they end up with the correct project and an ajax pager but the url is always /singlenode_view?page=[somenumber].
What about all my nice pathauto urls for each of those project nodes? Fail....
Along comes Jeff Eaton with his nice
Custom Pagers module. (I find these things well after I have tried this all on my own...). I was just about to do some custom programming to get my next/previous node id's from my view when I found this module.
Fantastic.
Installed. Enabled. Now I can have a block that displays my next an previous links based off of either custom php code, or an existing View. What do you know, I already have that view. Set, place block, done.
I did run across the 10 items only bug as I had installed the 6.x-1.10-beta1 version. Apparently, if you are using 6.x you want the dev version. After removing the beta version and installing the dev version things were peachy. See the blog post about it
here. I did
not have to implement the "Pager Node List" code they list on that post with the dev version I downloaded today.
So a huge thanks to
Jeff Eaton and
Lullabot for all that they do for the Drupal community. You saved my can today and I owe you a beer.
Comments (0)
Leave a comment...