What would it take to get node queue to generate a daily random node from the queue? In other words, rather than the node_fetch_random function generating a new random node every time the page updates, the module checks the date and displays the same random node throughout that day. When the day changes, so does the node.
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | shuffle.patch | 928 bytes | colan |
Comments
Comment #1
merlinofchaos commentedYou need to write a little bit of code that checks the time and the last time nodequeue_fetch_random was called; if now - time > 24 hours, or no result is stored call nodequeue_fetch_random and store the result; otherwise, fetch the result. Return the result.
This won't be a feature of node queue itself, but the code to do it is pretty short, and would make a good PHP snippet in the handbook.
Comment #2
droopy commentedThanks. That's beyond me though, so if any can help out, I'd appreciate it.
Comment #3
merlinofchaos commentedComment #4
merlinofchaos commentedBTW if this is useful to someone, reposting this in the snippets section and closing this issue would be awesomely helpful!
Comment #5
discursives commentedI tried this out and I get an error, where I had been using the simple random function with the same queue and that was working.
Every 3rd or fourth try there would be no content for the random one. This gets an error every time though.
I think I am just going to use the random function for views, though. I would like it to be sequential from a view, and daily, in all truth. I know that most sites won't have those requirements, but hey, at least i know what I need!
Comment #6
discursives commentedDid anyone else get this to work by any chance?
Comment #7
colanI came up with a similar but different solution because I needed to use views. If would be great if this could make it into the module; clearly I'm not the only one that needs this.
I wrote a little patch that provides the function nodequeue_queue_shuffle() that shuffles a queue. The idea is that this can be called from cron whenever it's necessary. For example, I call it once a day:
Comment #8
merlinofchaos commentedI did this and went one better, putting it in the UI and providing some javascript to do the same thing from the UI. Both methods work.
Note that the patch as given does not apply to the 2.x branch because it was referring to queues, and 2.x needed subqueues.
This'll go out in Nodequeue 2.x-rc
Comment #9
(not verified) commented