You are here

php_eval_snipps.txt in Simplenews Scheduler 7

Same filename and directory in other branches
  1. 6.2 documentation/php_eval_snipps.txt
from 6.x-2.x Simplenews Scheduler can additionally only send a newsletter if the provided PHP Eval code returns true.

Some examples to follow.


Check the current forecast using weather underground, if the weather for the next week is going to be warmer than a threshold,
then allow the newsletter to be sent. (Hey come to my place, it's going to be warm this week!, and use the insert_views module
to include a list of fun things you have planned)


  $threshold=20;
  $total = 0;
  $i=1;
  $xml = new SimpleXMLElement(file_get_contents('http://api.wunderground.com/auto/wui/geo/ForecastXML/index.xml?query=Tallinn,Estonia'));
  foreach($xml->simpleforecast->forecastday as $forecast) {
    $i++;
    $total+=(string)$forecast->high->celsius;
  }
  if($total > $threshold) {
    return true;
  }
  return false;

File

documentation/php_eval_snipps.txt
View source
  1. from 6.x-2.x Simplenews Scheduler can additionally only send a newsletter if the provided PHP Eval code returns true.
  2. Some examples to follow.
  3. Check the current forecast using weather underground, if the weather for the next week is going to be warmer than a threshold,
  4. then allow the newsletter to be sent. (Hey come to my place, it's going to be warm this week!, and use the insert_views module
  5. to include a list of fun things you have planned)
  6. $threshold=20;
  7. $total = 0;
  8. $i=1;
  9. $xml = new SimpleXMLElement(file_get_contents('http://api.wunderground.com/auto/wui/geo/ForecastXML/index.xml?query=Tallinn,Estonia'));
  10. foreach($xml->simpleforecast->forecastday as $forecast) {
  11. $i++;
  12. $total+=(string)$forecast->high->celsius;
  13. }
  14. if($total > $threshold) {
  15. return true;
  16. }
  17. return false;