1

I would like to implement a reminder functionality on a website, where a (anonymous) user can define a time for a (pop-up) reminder to fire automatically. Think of it as a digital egg timer, where you are reminded after some 5 minutes that your eggs are hard boiled... ;-).

My initial idea was to save the due time in $_SESSION['reminder'] and let Drupal check at each cron run whether the reminder is due. However, this approach fails because hook_cron operates on a global level and therefore does not recognise $_SESSION variables. On the other hand, saving the due time in, say, a node field does not make sense either: Drupal would find all due reminders and fire a pop-up which would be visible to every user currently on the site! So summing up, I need to find a way to initiate a process at a given time that is restricted to a particular session. Can anyone give me advise on how to go for this one?

Also, I need the reminder to pop up at the very top of all running applications in order not to be missed by the user. This is obviously something that all pop ups would like to achieve, so a user would probably have to give special pop-up permissions to this site. But how can I program such a pop-up, and what special settings are required? Alternatively, I could display the reminder as a (browser independent) system message, like the messages when receiving an MS Outlook email for example. Does anybody know whether and how this can be easily achieved?

I am sorry that this request is a bit vague, but it's really more about the general strategy and I haven't reached the level for detailed questions yet. So I would highly appreciate your ideas and experiences in similar applications in order to get inspired.

4
  • 2
    At this generic stage, I think this question would be a better fit on stack-overflow, and only asked here once there is an implementation strategy.
    – Letharion
    Commented Mar 20, 2012 at 10:34
  • 2
    How precise does this need to be? My idea of an egg time is down to the second, but you won't be running cron every second I'd imagine... Commented Mar 20, 2012 at 11:15
  • i would work with javascript and cookies ..
    – rémy
    Commented Mar 20, 2012 at 13:12
  • A precision of 1 minute should be fine. And I do run cron every 1 minute (at least the part of cron that is checking the reminders...)
    – tobias
    Commented Mar 23, 2012 at 8:42

1 Answer 1

1

You have two approaches.

You could create a non cacheable block, that will check a session_variable, if a timer is set and the time is passed. If is has, it will render something, else it will be invisible. The will create the pop up on page refresh.

Alternative you can use a javascript and use setInterval to check if the time has passed and then display a popup. You would then have to add the javascript info on page load.

1
  • After all, it worked out nicely with setInterval and getting the data into Javascript with Drupal Behaviors. Thanks for your advice (although it comes a bit late :-)
    – tobias
    Commented Sep 8, 2013 at 10:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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