- ππ·Croatia portulaca
@liquidcms it's not working for me, I get a WSOD when I try to send an example mimemail and this in the log:
Error: Class "LanguageInterface" not found in mytheme_preprocess_mimemail_message() (line 41 of /var/www/html/name/web/themes/custom/mytheme/mytheme.theme)
β¦ - π¬π§United Kingdom rivimey
@portulaca It sounds like you need a 'use' statement for LanguageInterface in the file that you have added the code from #10 to. I can't recall the exact place but something of the form:
use \Drupal\Core\...\...\LanguageInterface;
Search existing code for examples.
- ππ·Croatia portulaca
@rivimey thank you!
It's
use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Url;
It's working now, although I'm getting a double slash in the CSS link path
https://example.com//themes/custom/β¦
Should the variable be without it?
$variables['mail_css'] = $base_path . 'themes/custom/my_theme/css/mail.css';
- First commit to issue fork.
- πΊπΈUnited States tr Cascadia
@malcomio: Are you planning on working on this issue?
- π¬π§United Kingdom malcomio
In the project where we're using mimemail, we ended up adding a preprocess in our theme, as suggested in #10, and I haven't had a chance to make progress on a contributed version.
- πΊπΈUnited States aytee
We used the preprocess theme suggestion as in #10. This successfully includes the mail.css file.
- π΅π±Poland pawel.traczynski Warsaw
Hi. The method from #10 is adding a link to the mail.css in the mimemail-message template. From what I saw it did not work in all cases. To actually add the CSS into the template, I have used the below code:
/** @var \Drupal\Core\Extension\ThemeHandlerInterface $theme_handler */ $theme_handler = \Drupal::service('theme_handler'); $theme_path = $theme_handler->getTheme('YOUR_THEME')->getPath(); $css = FALSE; // Assuming mail.css is in a /css subdirectory where all other css is. $css_path = DRUPAL_ROOT . '/' . $theme_path . '/css/mail.css'; try { $css = file_get_contents($css_path); } catch (Exception $exception) { Drupal::logger('YOUR_THEME')->error(t('Failed to get contentns of mail.css file while using mimemail-message template. Exception message: @exception', [ '@exception' => $exception->getMessage(), ])); } if ($css) { $variables['css'] = $css; }
With this code there is not need to modify the mimemail-message twig template unless you want to add some additional markup in it.
I hope this helps someone.