|
For automatic updating the feeds you will need to call the feedcron periodically. On unix style systems this is usually done using a cronjob. Most hosting providers allow to set up some cron.
There are two options calling the webpage using w g e t, curl or lynx. Or using the CLI version of php. The choice depends on the availability using the CLI version is highly recommend, this avoids max_execution_time problems.
a typical webpage request looks like:
0 4 * * * w g e t http://www.example.com/administrator/components/com_datafeeds/cron/feedcron.php
(remove the spaces in w g e t)
a typical command line call:
0 4 * * * (cd [path to the feedcron];php feedcron.php)
pseudo cron
Another option is to use a pseudo cron using your site visitors. This will work fine with small and/or a limited number of feeds.
The tmpl code below will periodically call the feedcron refreshing a single feed.
- put the code below in the script JOOMLA_ROOT/modules/mod_datamenu/tmpl/cron_custom.php
- you need a dummy feed as a semaphore/lock to avoid running multiple imports at once. Create a new feed, put in a name, click apply, ignore the messages but remember the number after cid[]= in the url, click save. don't publish.
- create a new mod_datamenu menu, select the cron_custom template. Put the module way down in your template, most templates have a module position 'footer' near the bottom.
- put the number from step 2 in the field 'default id' using a minus sign, thus if you got 19 put -19 in the box
- In the grid put in the minimal interval between importing a feed in minutes. do your math, when running 200 feeds with an update frequently of a day you will never get everything imported when using a 30 minute interval.
- publish the module.
- After a while you should see the 'last update' time of your dummy feed changing and feed should follow.
- Monitor the downloads for a while.
<?php // no direct access # # Copyright brambring.nl # http://www.affiliatefeeds.nl #
Dit e-mailadres is beschermd tegen spambots. U heeft Javascript nodig om het te kunnen zien.
# defined( '_JEXEC' ) or die( 'Restricted access' ); function Datacron_customMenu(&$dataitems,&$params) { $image=false; $id=$params->get('id'); $freq=$params->get('grid',60); $query="update #__datafeeds set last_update=now() where feed_id = $id and (`last_update` + interval $freq minute< now())"; $db =& JFactory::getDBO(); $db->setQuery( $query); $db->query(); $hits=$db->getAffectedRows(); if ( $hits > 0 ) { $query='SELECT feed FROM `#__datafeeds` WHERE (`last_update` + interval `freq` second< now()) AND published>0 ORDER BY rand()' ; $db->setQuery( $query, 0,1); $feed=$db->loadResult (); $hits=$db->getAffectedRows(); if ( $hits ) { $image=JURI::Base()."administrator/components/". "com_datafeeds/cron/feedcron.php?feed=". urlencode($feed); } } if ( $image) { echo '<img src="'.$image.'" alt="auto cron '.$feed.'" style="width:1px;display:none"/>'; } }
|