I am about to make an RTL Persian MODx auto reset demo (showcase) site, something like opensourcecms.com that resets the db changes made by users to default installation, seems to me i have to go for it by CronJobs? if so give me a clue were to start?, let me know in case if MODx demo site could be done in another way.
Any comments are welcome :-]
Thanks!
-
☆ A M B ☆
- 24,524 Posts
Yes, that’s a job for cron.
Although it could be done with a plugin... if you thought enough people would be logging in to the Manager, you could use the onlogin (whatever it’s really called) event and if it’s after a given date/time clear the database, and reset the date/time (you could use a simple text file to keep the date/time to reset, like the cache does for publishing/unpublishing).
I’m intrigued. How would you go about setting this up?
-
☆ A M B ☆
- 24,524 Posts
Set up the demo site the way you want it (including the plugin below). Dump the database with "drop table" added. Save the .sql file. In the same folder, have a text file that has nothing but a timestamp (current time plus however many seconds until you want the next refresh).
Make a plugin that is set to trigger on the OnManagerLogin or OnManagerLogout event. Have the plugin grab the timestamp file. If the current timestamp is greater than the one in the file, import the .sql file into the database, add the amount of time desired to the timestamp for the next refresh and write it back to the timestamp file. The code can also empty any folders in the assets folder you allowed uploads to; file uploads should have been limited to images only.
A cron job would do pretty much the same thing; simply import a saved .sql file to restore the database. It would just use the cron timing features.
Thanks Susan, which plugin are you refering to?
Many thanks Susan, I’d rather prefer to go with cron as it seems promising, I’ll be doing this tonight/tomorrow and may come back with questions on clueless points. Thanks!
-
☆ A M B ☆
- 24,524 Posts
I think most domain control panels have cron job "wizards", so it shouldn’t be too bad.
I see no option to select for themes in installer, How can i have my customized rtl-modxhost front-end theme installed by MODx demo content?
Any idea about what command should be entered in order to run cron?
-
☆ A M B ☆
- 24,524 Posts
Manager themes are automatically added to the drop-down in the Configuration when they are physically uploaded to the manager/media/style folder.
http://www.unixgeeks.org/security/newbie/unix/cron-1.html