Hi !

Thanks for this really useful module.

I have a very strange bug. I can't override mimemail.tpl.php with my own version. I use a zen subtheme. I tried to put my file in sites/all/themes/mytheme, sites/all/themes/mytheme/theme, sites/all/themes/zen, and sites/all/themes/zen/theme, but the module version is always used. I refreshed the theme registry before each try. Would anybody have an idea ?

Comments

guillaumeduveau’s picture

Same here

gregarios’s picture

Ditto...

brei9000’s picture

Same issue.

guillaumeduveau’s picture

There's a new related issue I'm marking as a duplicate of that one (#614920: mimemail.tpl.php not loaded from custom theme).

Gregarios and brei9000, is your theme a subtheme of Zen as well ?

gregarios’s picture

Gregarios and brei9000, is your theme a subtheme of Zen as well ?

I'm not using Zen or any subtheme. I'm using a custom theme.

yrocq’s picture

It may be related to Simplenews : http://drupal.org/node/374222 (Template files do not work when using admin theme). I will check this next week.

gregarios’s picture

It may be related to Simplenews

I'm not using simplenews, but Subscriptions Module, and there is still a problem with this.

aschiwi’s picture

Same issue for me and I'm not using Zen. Am using Simplenews though (but Simplenews templates are working fine from the theme directory)

brei9000’s picture

I am using Zen and Simplenews.

jlyon’s picture

I have the same problem using Zen and Simplenews too.

yrocq’s picture

My problem was because I checked the box "Use administration theme for content editing" in Administration theme settings. When I sent a newsletter issue, drupal looked for the custom template in the admin theme directory instead of the global theme one.

Upgrading from simplenews rc6 to stable version solved the problem. I let this issue open because other people have the same problem without using simplenews. However, the problem may be caused by the same kind of bug, so it may be a good thing to post an issue to the page of the projects that send the mail (like Subscriptions).

visios’s picture

Same problem here here with Zen, Simplenews 6.x-1.0 and MimeMail 6.x-1.0-alpha1.

yrocq’s picture

Assigned: yrocq » Unassigned
Anonymous’s picture

StatusFileSize
new1.57 KB

This is my solution.

1.
Rename template file 'theme/mimemail.tpl.php' to 'theme/mimemail_message.tpl.php'.

2.
Change 'mimemail' to 'mimemail_message' in mimemail_theme_theme() function.
theme/mimemail.theme.inc:
- 'template' => 'mimemail',
- 'pattern' => 'mimemail__',
+ 'template' => 'mimemail_message',
+ 'pattern' => 'mimemail_message__',

3.
Remove file include in mimemail_theme() and create init hook.
This is necessary, without this module is not including 'mimemail.theme.inc' file and doesn't call preprocess function.
mimemail.module:
function mimemail_theme() {
- module_load_include('theme.inc', 'mimemail', 'theme/mimemail');
return mimemail_theme_theme();
}

+/**
+ * Implementation of hook_init().
+ */
+function mimemail_init() {
+ module_load_include('theme.inc', 'mimemail', 'theme/mimemail');
+}

===

Hope this helps.

dsms’s picture

subscribe

rfay’s picture

Status: Active » Needs review
StatusFileSize
new5.11 KB

This patch follows up #14, and ends up working fine for me. This simplifies the path just a bit. The mimemail.tpl.php gets moved right out into the module directory. The theme directory is removed and logic moved into the .module file.

This also avoids problems caused by #591804: Theme registry build bug: External file with template_preprocess is not loaded if tpl.php is copied into theme, which has not yet been committed to core D6. But this problem was *not* caused by that issue. However, simpler paths keep the theming layer saner, so this is IMO a good thing.

Please try this out and report your results back. Set it to RTBC if you think it is.

sgabe’s picture

I couldn't either override the mimemail.tpl.php from my custom theme with using another administration theme. It seems, you have to place the modified template files in your administration theme (whatever it is), it will be loaded from there.

@rfay: I tried your patch. I was about to do those modifications that you made, to see if that helps, but as I wrote above it didn't work out. Not even with an own hook_theme() in my theme with a given path. I tried manipulate the theme registry, I was able to modify it to see my theme registered with the mimemail_message but it didn't work anyway.

plach’s picture

StatusFileSize
new3.32 KB

I tried the attached variant of #16 and seems to work well with MimeMail 6.x-1.0-alpha1 + Simplenews 6.x-1.0 with the patch attached to #374222-73: Template files do not work when using admin theme applied (admin theme and admin theme for content editing ON).

Before patching Simplenews the attached patch seemed not to work because Simplenews couldn't select the right theme.

Currently the embedded styles are the ones of the admin theme but this can be fixed by using a mail.css stylesheet in the custom theme root or by overriding the css variable via a template preprocessor.

sgabe’s picture

Status: Needs review » Needs work

I don't think that the described solution in #14 and #16 is the right one. These changes break more things than fix (according to other issues waiting to be reviewed and committed), but I tried rfay's patch and it didn't work. (By the way, the path is wrong in the patch, you should use the module directory's root to patch creating.)

Before patching Simplenews the attached patch seemed not to work because Simplenews couldn't select the right theme.

I tried again with Simplenews 1.x-dev which should fix a referring issue as plach wrote, but no change at all.

I think right now the best solution, if you are using another administration theme than your default theme, is to place mimemail.tpl.php into that theme's folder, until a real fix comes.

rfay’s picture

@squabe: #18 seems to have rerolled my patch in #16 that had the wrong root. I apologize for that.

Note that it is conceivable that all this might have shifted in drupal-6.16, since #591804: Theme registry build bug: External file with template_preprocess is not loaded if tpl.php is copied into theme was committed. However, I'm still happily using the solution in #16, now with Drupal 6.16. It completely solved my issue.

@squabe: I encourage you to mention what things you think this patch breaks that are fixed and ready to commit, and give some links. Not sure if I'm willing to work on this extensively, since I have a good fix, but I may. We also haven't had Allie chime in on anything here.

sgabe’s picture

I have tested this workaround on a clean Drupal 6.16 install with Simplenews 1.0 and 1.x-dev with these steps.

  1. Moved Chameleon theme into sites/all/themes.
  2. Set default theme to Chameleon.
  3. Set administration theme to Garland, for content edition too.
  4. Copied mimemail_message.tpl.php into Chameleon's folder under sites/all/themes.
  5. Modified the template file to know if it is used.
  6. Added myself to the default newsletter which ships with Simplenews.
  7. Created a new newsletter issue using HTML format and sent it.
  8. Fired cron to send the pending newsletter.

E-mail arrived with no change. The module's template file is used every time. If the template file moved into Garland's (the selected administration theme) folder, everything is sunshine and happiness (at least a little bit).

@rafy: Following these steps can you send a customized newsletter?

I think this is not even a bug in MimeMail, but a bug in Drupal itself, and this issue here will be a won't fix. Perhaps your patch works with Zen, but it's not a general solution to the problem. The same goes with Simplenews in this #374222: Template files do not work when using admin theme. Perhaps that solution works with the Admin module, but doesn't solve the issue in general.

Guys, who are just watching, any feedback on this would be appriciated. Please help test this and report back, what did you experience.

sgabe’s picture

Status: Needs work » Needs review

I am deeply sorry. After hours of processing the issue queue, noticed just now that the theme I picked for testing is a Plain PHP theme... My bad. Anyway, I have a good news and a better news. The good, that rfay's solution works after all. The better one, I think there is no need for that. :-)

With Mimemail 6.x-1.0-alpha1 and Simplenews 6.x-1, to override mimemail.tpl.php you just have to use mimemail-message.tpl.php in your theme folder and there is no need for any other modification! Please, try this on a clean install, and confirm it. You have to do nothing, just copy mimemail.tpl.php into your default theme folder and rename it to mimemail-message.tpl.php, it will be loaded just fine.

bkonetzny’s picture

Can confirm that renaming the file in your template folder to mimemail-message.tpl.php is working.
But I think it's a little bit confusing, normally you don't have to rename template files?

sgabe’s picture

Status: Needs review » Fixed

The hook_theme() contains the mimemail__ pattern, and the module calls the theme() function with this pattern theme('mimemail_message', $body, $mailkey). So, if you have the mimemail-message.tpl.php in your theme folder, that will be used. If you don't, it falls back to the generic mimemail.tpl.php in the module's folder.

sutharsan’s picture

Status: Fixed » Needs review
StatusFileSize
new770 bytes

I agree with Majestixs that using a mimemail-message.tpl.php as override of mimemail.tpl.php is very unusual and it is not documented. This is probably caused by a missing implementation of hook_template(). Attached patches does this.

TODO: documentation in mimemail.tpl.php

EDIT: oops. Ignore this comment and patch. mimemail_theme() is already there.

chill8331’s picture

To#22

Not working for me! If you print out vars from template_preprocess_mimemail_message

[template_files] => Array
        (
        )

Is there something missing? I suppose it shouldn't empty.

And i'm curious how to theme the body content? What template is using for this var? Is that possible theme it as a node?

Struggling on this for days! Looking for help!

sutharsan’s picture

StatusFileSize
new2.21 KB

The behaviour has nothing to do with the declaration of the pattern ('mimemail__') as stated in #24. It is in fact caused by the difference in name of the theme function ('mimemail-message') versus the name of the template ('mimemail'). Without going to deep into the plumbing, template override only works the way we know it if the theme function has the same name as the template file. To correct this we have two options with its own drawbacks:
* Change function name (to 'mimemail')
- Need to change preprocess function name. This will break existing preprocess overrides
- Will break existing template overrides
+ only changes in code
* Change template file name (to 'mimemail-message')
- needs CVS file changes

The attached patch does the latter.
TODO: documentation in mimemail-message.tpl.php

sgabe’s picture

@Sutharsan: Hmm...you are probably right. With the pattern removed still the same, it seemed a reasonable explanation. IMHO the best way is to rename the template file to mimemail-message.tpl.php. However I chose this way in #743150: Mime Mail 6.x-1.0-beta1?. I would leave the pattern in order to support features like #319384: Add $mailkey to body tag as CSS class.

sutharsan’s picture

StatusFileSize
new2.2 KB

I have no objections against using the pattern. But I removed it while there was no use of it in the current code. Revised patch does not remove the 'pattern' from the theme definition. I leave further modification of the theme('mimemail-message') to issue #319384: Add $mailkey to body tag as CSS class

planctus’s picture

Is there any chance to have the patch rerolled for the alpha2 version?
I've got into this issue trying to override the mimemail template and i had to switch to the dev version since the patch wouldn't have worked with the alpha2.
But now i see the dev is older and drupal is always asking me to update this module beacuse there's a security update in it...
Thanks,
Da.

Mac Clemmens’s picture

I am having a problem where I have created mimemail-message.tpl.php in the theme folder, but now my theme's mail.css file is not getting processed and added into the theme. If I just hack mimemail.tpl.php in the module directory, it continues to read the mail.css and puts the styles inline like it's supposed to, but obviously I don't want to change the .tpl.php file in the module. Is anyone else having this problem? I'm going to try a fresh install with the latest versions of everything, but I believe it is CRUCIAL to test that the mail.css file in the theme directory will get embedded correctly when using mimemail-message.tpl.php to override your template.

planctus’s picture

I used this function to change the path where it looks for the css to add.
Find it in the mimeail.module and override it in your theme's template.php file.

function template_preprocess_mimemail_message(&$variables)

See you,
Da.

jerdavis’s picture

Status: Needs review » Fixed

Committed to HEAD

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

jm.federico’s picture

Status: Closed (fixed) » Fixed

Changing status.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

roball’s picture

Version: 6.x-1.x-dev » 6.x-1.0-alpha3
Priority: Normal » Critical

"theme/mimemail.tpl.php" is tried to be included (but missing), also in 6.x-1.0-alpha3. This causes the following PHP error:

include(./sites/all/modules/mimemail/theme/mimemail.tpl.php) [<a href='function.include'>function.include</a>]: failed to open stream: No such file or directory in /usr/share/drupal/includes/theme.inc  on line 1066.
roball’s picture

Status: Closed (fixed) » Needs work
rfay’s picture

Status: Needs work » Fixed

The name of the template is now mimemail-message.tpl.php, and it's there in alpha3, in the theme folder.

I deployed simpenews+mimemail just this week successfully (and with moving mimemail-message.tpl.php to the theme's folder).

I'm suspecting that you have a corrupted install? I'd say, delete the existing mimemail and get the current and install it. Also: Make sure you rebuild the theme registry (or clear all caches) as if you just copied in the new module, your theme registry could be out of date. You can rebuild the theme registry by going to the Performance page at admin/settings/performance and clicking the "clear all caches" button.

roball’s picture

Version: 6.x-1.0-alpha3 » 6.x-1.0-alpha2
Priority: Critical » Normal

Oh yes, I had to clear all caches and got rid of the error. Thanks and sorry for the false-alarm.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.