I noticed the cron does not uses the template files.
Test mail and sending without cron are using the template files correctly (if exist in theme folder)

Regards

Comments

sutharsan’s picture

Is it just cron not using the template files? Does it work with poormanscron, test-emails, send immediately without cron? Did you update the registry?
If it is only cron, I think the whole email sending by cron has to be reviewed. Cron does not do a full bootstrap (related issue) which may cause it to skip drupal's theming abilities.

sutharsan’s picture

What version of Drupal do use? (See #344625: Themes disabled on cron)

Docc’s picture

Im using 6.8.

With test-emails/send immediately without cron it works fine.
Did not used poormanscron.

So its only cron. Il take a look at the bootstrap issue and report back.

sutharsan’s picture

Cron does a full bootstrap (see cron.php). I realized that cron runs as anonymous. Is the theme visible for anonymous users?
See: #256795: Allow simplenews cron to send nodes that anonymous users cannot access

pieterbezuijen’s picture

I'm using Drupal 6.9 and also got problems with templates and cron.

Tried applying patch metioned in #4, no succes. My theme is visible for everyone.

I took a closer look to the e-mail that is sent and saw that the mail.css is attached, could this be a mimemail issue?

sutharsan’s picture

sutharsan’s picture

@pieterbezuijen: mail.css is attached by mime mail.

sutharsan’s picture

Status: Active » Closed (won't fix)

I have tested, but can not reproduce the problem. Getting the theme registry to recognize the new .tpl.php is not easy. But when it does, cron does use the template files. Marking it as won't fix.

sutharsan’s picture

Docc’s picture

Finally found the time to look into it. And could bang my head into the wall for not thinking about this earlier.
I use a different theme for the admin pages including for editing content.

So when i send without cron it uses the admin theme. When sending wit cron it uses the theme for the anonymous user.

So you could say this is a Drupal design issue (its a design problem i think) but it could be a good practice for simplenews to always send a newsletter as anonymous.

pieterbezuijen’s picture

Wow! This works:D Thanks Docc!

I use Rootcandy as admin-theme, but all template files are in my normal theme. Tried copying my template-files to the Rootcandy-theme and this works.

Would this be a Drupal issue?

webel’s picture

Priority: Normal » Critical

I would like to confirm this problem. When sending Newsletter (after editing) as admin or as any role authorised to send newsletters - and ONLY when using Cron - the template files are skipped ! Left me completely bamboozled until I found this issue report (many thanks). My template files are under the main site theme.

drupalfan2’s picture

Status: Closed (won't fix) » Needs work

When will this problem be solved?

hansrossel’s picture

Status: Needs work » Active

I'm having the same problem.

My installation uses Rubik/Tao (which are the admin themes from the admin module) as the admin theme.

- Test version: When sending the test newsletters the custom front theme of the site is used and the simplenews-newsletter-body--25.tpl.php template files in there. php code in my template file is printed and the views_embed_view code in there.
- Sending directly: When sending the real newsletter directly (so not using cron) the custom front theme of the site is used and the simplenews-newsletter-body--25.tpl.php template files in there. php code in my template file is printed and the views_embed_view code in there.
- Sending on cron: When sending the real newsletter on cron the admin theme Rubik is used and the simplenews-newsletter-body--25.tpl.php template file inside Rubik. php code in my template file is printed BUT the views_embed_view code is not printed.

I tried it both with htmlmail and mimemail, same result. Using normal cron, not poormanscron.

sgabe’s picture

Status: Active » Closed (duplicate)
aries’s picture

The root of the views_embed_view() problem can be the different language filter.

Eg:
The i18n.module overwrites the query in the sanitize part of nodereference_field() in nodereference.module (around line 262). If the sites' default language is 'en' (because the admin forget to give a prefix for the english language) but the user who checks the site has the default language 'nl', then the view will execute different queries for cron runs and for the user.

Fortunately, in the nodereference case, you can override this in the formatter's theme function. Eg.

/**
 * Theme function for 'default' nodereference field formatter.
 */
function phptemplate_nodereference_formatter_default($element) {
  $output = '';

  // This block is the key. Not the best thing to put a query into a theme function, but it's a hotfix. :)
  if (empty($element['#item']['safe']['nid'])) {
    $element['#item']['safe'] = db_fetch_array(db_query('SELECT n.nid, n.title, n.status FROM {node} n WHERE n.nid = %d', $element['#item']['nid']));
  }

  if (!empty($element['#item']['safe']['nid'])) {
    $output = l($element['#item']['safe']['title'], 'node/'. $element['#item']['safe']['nid']);
    if (!$element['#item']['safe']['status']) {
      $output = '<span class="node-unpublished"> '. t('(Unpublished)') ." $output</span>";
    }
  } else {
    db_fetch_object(db_query('SELECT n.nid, n.title, n.status FROM {node} n WHERE n.nid = %d', $element['#item']['nid']));
  }
  return $output;
}

To debug the views and cck shorten the people's lifetime more than the Philip Morris. ;)

kumkum29’s picture

Hello,

I'm having exactly the same problem.
Did you find a solution with the cron ?

mordonez’s picture

In D7 you can resolve the problem running the cron outside of admin, as http://domain.com/cron.php?cron_key=XXXXXXXX