Simplenews Scheduler is working well for me to send a weekly email which contains an attached view (using EVA) of nodes.
I would like the newsletter to only send if the attached view contains nodes, so that empty newsletters are not sent.
I can see that this should be possible using the 'Additionally only create newsletter edition if the following code returns true' field on the Newsletter > Send newsletter according to schedule page. I am currently using this (which always produces a newsletter regardless of whether nodes are displayed in the view):
if(views_get_view('job_type_c_list')) {
return true;
}
I have tried using the overall length of the node body to try to work out if a view is present. (I don't know if the tokens can be used in this field or not):
if(views_get_view('job_type_c_list')) {
$myvar = [node:body:?];
if(strlen($myvar) >= 30) {
return true;
}
}
When i was working with PHP in the body of the node I was able to evaluate whether EVA was returning nodes by using
<?php
$view = views_get_view('job_type_c_list');
$printedview = $view->preview('default');
$myvar = (string)$printedview;
if(strlen($myvar) >= 1000) {
print "VIEW ATTACHED";
}
else if(strlen($myvar) < 1000) {
print "NO VIEW ATTACHED";
}
?>
The above code is clearly not the most elegant, but it worked in the node itself. Unfortunately it didn't work in the 'Additionally only create newsletter edition if the following code returns true' Simple news scheduler field.
I have struggled with this for quite some time and would really appreciate some help. Code suggestions would be great, but failing that knowing 'If I can use tokens in the field?' and 'why does the PHP in this field behaves differently to PHP the node itself?' would also be very helpful.
I have had an issue open in the module issues page for a few days now, but it has not received any responses.