I have been trying to create a "node of the day" via Views and, after reading your module description, I thought my prayers had been answered.
I have set up a view to show a random node (with some filters). I have set the views cache to 6 days. If I can get the cache to reset daily, then I will have a random node which changes on a daily basis - exactly what I need without writing custom modules. This all sounds good.
My problem comes with setting up Cache Actions. Where do I configure it? I have set up a Rule which I need to associate with clearing the cache of my view, but cannot find out where to configure the action. I have looked in Actions and I have looked in Rules, but there does not seem to be anything new to set up.
Comments
Comment #1
fabsor commentedHi!
You will need the following modules enabled:
* Views
* Rules
* Rules UI
* Cache Actions
* Rules Scheduler
This steps worked fine for me:
* Go to rule sets (admin/rules/rule_sets)
* Click "Add new rules set"
* Fill in the required values (nothing more is required) and click save.
* Click on you new rule set on the overview page (which you were redirected to).
* Click "Add new rule"
* Give the rule a name, and make sure your newly created rule set is selected in the rule set select list.
* Click "Add an action"
* Select "Clear the cache of a specific view." in the list and click next.
* Select you view in the list.
* Hit "save".
* You now have a rule set. You can now schedule it with rules scheduler.
* Hit the "Scheduling" tab on the overview page for rules.
* Select your rule set.
* Add an appropriate time to clear the cache.
You could also try adding a triggered rule on cron, and then use some condition to check if the appropriate amount of time has passed.
Let me know if you still have problems!
Comment #2
SweeneyTodd commentedThanks for this.
I eventually managed to piece together something pretty close to this. My problem was really with the Rules module as it is not an easy beast to try to figure out for a newbee - the workflow for creating rules is not obvious. In case any of the Rules developer read this - a few more notes on the user interface or help buttons linked to Advanced Help to explain what to do could save new users hours.
The rule set I created had 1 rule with 2 actions: the first clears the cache and the second reschedules the rule.
By scheduing the rule for 23:59 it will run at about midnight (the next cron run) and the scheduled time for the next one will be 23:59 the next day. The trick here is to schedule the rule for just before midnight and have it run (via cron) just after so the rescheduled rule is the same time the next day. I could have used "+1 day" as the sceduled time, but this could lead to the time creeping and would be thrown out completely by a server upset; I think this might keep the intended time though.
I left a test running overnight and it seems to work ok - the cache was cleared and a different node is being displayed. The new scheduled rule has been created ok. Your module seems to work fine even though it is an alpha release - good work.
I have now added a Log to Watchdog action to the rule as well so I can track it for a few days to make sure it works as planned.
I have closed the issue.