In the past (before contao3) I was able to present a folder to the front end users with daily reports automatically generated. How can I automaticlly sync every morning the folders so that my files are picked-up?
thx
Printable View
In the past (before contao3) I was able to present a folder to the front end users with daily reports automatically generated. How can I automaticlly sync every morning the folders so that my files are picked-up?
thx
I think you need cron. There is an extension called cron or you can setup real cron at the server.
There is a description in this blog how to use cron: http://blog.qzminski.com/2010/05/how-to ... ur-module/
This description assumes the Contao cron. You need some adjustments to use a real cron. Easiest is to open cron.php with the real cron on the shortest timespan you require and let Contao handle what and when.Quote:
Module config
First of all we need to assign a task to the TYPOlight cron. This is done in module’s config file. Open the config/config.php and add:
Cron tasks can be executed either hourly, daily or weekly. In the array we specify the php class and function that will be executed.Code:/**
* Cron jobs
*/
$GLOBALS['TL_CRON']['daily'][] = array('LeagueTable', 'getData');
Get the data
The LeagueTable.php contains following:
There are two important things here. The function you execute has to be public, but that’s obvious.Code:<?php
class LeagueTable extends Frontend
{
public function getData()
{
// curl_init
// regexp & DOM
$this->Database->prepare("UPDATE tl_leagueinfo SET tstamp=?, table_info=?, WHERE id=1")->execute(time(), $arrTable);
}
}
?>
Secondly, the class has to extend Frontend! At the first, I have put this method into the ModuleLeagueTable class which extends Module. That was a mistake, because cron job will not execute unless its class extends Frontend.
Also, if you use a modified frontend template fe_*.tpl, do not forget to put the
Or your code won’t be executedCode:[img]<?php echo $this->base; ?>cron.php[/img]
Thanx for the answer, but i know I can schedule tasks via cron but the problem is the new file sync script in contao3.
Only file synced with the sync script are displayed in the front-end. This means I woul need to click evry day on the sync script to have the files displayed
Run the sync script through cron
Where is the sync script located?
It is DC_Folder::sync(). So you have to use/create a DataContainer object that is DC_Folder and call sync(). The sync script in Contao gets ran by the Backend class (Creates the datacontainer at around 253, calls sync at around 424 ($dc->$act()).
thanx!
I tried to do it like that (stupid as I am):
path to script: system/bin/filesync
but that didn't work.
How can I do that?
Nick