| lbuenaventura | could someone help me figure out how to pull off efficient windowed pagination? i have a photo gallery, and when a user views an individual picture, i want to have a window of 8 other images |
| pstickne | as much as everyone swears against the standard pagination... |
| lbuenaventura | the 8 images should represent, ideally 4 images to the left, and 4 images to the right of the image |
| pstickne | ...it works pretty easily. the layout of the images is simply in how you create the view |
| lbuenaventura | i'm not sure i can pull this off with standard pagination |
| pstickne | why not |
| lbuenaventura | let's say i give you the id of the individual image i need to be able to pull out the ids of 8 other images that "surround" it in the database table |
| pstickne | why thank you, it's a rather sexy id. okay. you can use the paginator with your own search results. |
| christophe971 | i'm drunk and sick ! it's the better time to RoR o/ ! let's code |
| lbuenaventura | how wouldi compute the offset? |
| pstickne | *shrug* which thing is actually moving? just the one item in the middle? |
| lbuenaventura | yes, exactly |
| pstickne | then the step is just one that sounds icky |
| lbuenaventura | sorry what do you mean? |
| pstickne | it sounds like a really messy sql query |
| lbuenaventura | i know, but the UI needs it |
| pstickne | because you're relying on relative position of rows |
| lbuenaventura | yes so i was wondering if perhaps there was a helper already out there that could do it or some other way around the problem |
| pstickne | I think the best way would be to change the table format slightly... but I'm not sure how. If there was a way you could guarentee proximity... even when say, things are removed. such as with an arbitary re-created index |
| lbuenaventura | the main issue is that the query also has conditions like "private<>1" and whatnot |
| pstickne | ... uhm. :) |
| lbuenaventura | so the data set you're pulling out is not necessarily sequential it's truly relative |
| pstickne | okay, here it goes... |
| sgrover | I thought scripttaculous was included with rais, no? I'm getting told Builder is undefined (builder.js is not available) |
| pstickne | search for what you're looking for, sort id, limit, search <= that id, maybe with a lower bounds, reverse sort and limit and that sounds ugly |
| lbuenaventura | yes, it sounds like something i'd do in php |