Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Mimemail does not pick up the file css/local.css in Fusion. This file is used to override styles so it's quite a big deal to not include it when the theme has been customized.
I don't know much about drupal/php/theming but it seems there could be some inspiration to be taken from ckeditor.module code:
// add custom stylesheet if configured
// lets hope it exists but we'll leave that to the site admin
$css_files = array();
switch ($conf['css_mode']) {
case 'theme':
global $language, $theme_info, $base_theme_info;
if (!empty($theme_info->stylesheets)) {
$editorcss = "\"";
foreach ($base_theme_info as $base) { // Grab stylesheets from base theme
if (!empty($base->stylesheets)) { // may be empty when the base theme reference in the info file is invalid
foreach ($base->stylesheets as $type => $stylesheets) {
if ($type != "print") {
foreach ($stylesheets as $name => $path) {
if (file_exists($path)) {
$css_files[$name] = $host . $path;
// Grab rtl stylesheets ( will get rtl css files when thay are named with suffix "-rtl.css" (ex: fusion baased themes) )
if (defined('LANGUAGE_RTL') && $language->direction == LANGUAGE_RTL && substr($path,0,-8) != "-rtl.css") {
$rtl_path = substr($path,0,-4)."-rtl.css";
if (file_exists($rtl_path)) {
$css_files[$name."-rtl"] = $host . $rtl_path;
}
}
}
}
}
}
}
}
if (!empty($theme_info->stylesheets)) { // Grab stylesheets from current theme
foreach ($theme_info->stylesheets as $type => $stylesheets) {
if ($type != "print") {
foreach ($stylesheets as $name => $path) {
if (file_exists($path)) {
$css_files[$name] = $host . $path;
// Grab rtl stylesheets ( will get rtl css files when thay are named with suffix "-rtl.css" (ex: fusion baased themes) )
if (defined('LANGUAGE_RTL') && $language->direction == LANGUAGE_RTL && substr($path,0,-8) != "-rtl.css") {
$rtl_path = substr($path,0,-4)."-rtl.css";
if (file_exists($rtl_path)) {
$css_files[$name."-rtl"] = $host . $rtl_path;
}
}
}
elseif (!empty($css_files[$name])) {
unset($css_files[$name]);
}
}
}
}
}
// Grab stylesheets local.css and local-rtl.css if they exist (fusion based themes)
if (file_exists($themepath . 'css/local.css')) {
$css_files[] = $host . $themepath . 'css/local.css';
}
if (defined('LANGUAGE_RTL') && $language->direction == LANGUAGE_RTL && file_exists($themepath . 'css/local-rtl.css')) {
$css_files[] = $host . $themepath . 'css/local-rtl.css';
}
// Grab stylesheets from color module
$color_paths = variable_get('color_'. $theme .'_stylesheets', array());
if (defined('LANGUAGE_RTL') && $language->direction == LANGUAGE_RTL) {
if (!empty($color_paths[1])) {
$css_files[] = $host . $color_paths[1];
}
}
elseif (!empty($color_paths[0])) {
$css_files[] = $host . $color_paths[0];
}
}
else {
if (file_exists($themepath .'style.css')) {
$css_files[] = $host . $themepath .'style.css';
}
}
$css_files[] = $module_full_path ."/ckeditor.css";
break;
case 'self':
if (file_exists($module_drupal_path .'/ckeditor.css')) {
$css_files[] = $module_full_path .'/ckeditor.css';
}
foreach (explode(',', $conf['css_path']) as $css_path) {
$css_path = trim(str_replace("%h%t", "%t", $css_path));
$css_files[] = str_replace(array('%h', '%t'), array($host, $host . $themepath), $css_path);
}
break;
case 'none':
if (file_exists($module_drupal_path .'/ckeditor.css')) {
$css_files[] = $module_full_path .'/ckeditor.css';
}
$css_files[] = $editor_path .'/contents.css';
break;
}
The above code contains ckeditor's patch found in #818378: Not all css files are loaded.
With that patch ckeditor also uses Fusion css/local.css for styling text in the editor.
Is there a quick fix I could apply to mimemail until a proper solution is found?
Comment | File | Size | Author |
---|---|---|---|
#4 | mimemail-load-local-css-file-920904-4.patch | 1.63 KB | fmjrey |
#2 | mimemail-load-local-css-file-920904-2.patch | 1.61 KB | fmjrey |
Comments
Comment #1
sgabe CreditAttribution: sgabe commentedPlease try out this patch in #443964: Skip style sheets with print media, maybe it picks up the local.css in Fusion and we can kill two birds with one stone.
Comment #2
fmjrey CreditAttribution: fmjrey commentedOk the patch in #443964: Skip style sheets with print media didn't quite cut it, but it's half of the solution I needed.
Here's a patch that includes #443964: Skip style sheets with print media and also checks for css/local.css, adding it if need be.
Now my emails are properly themed.
Thanks for your help!
Note: the description of this issue includes sample code that adds a lot more css files. I suppose these should be added as well.
Better yet, the real resolution should be in the core framework which should return those extra css...
Comment #3
geerlingguy CreditAttribution: geerlingguy commentedSubscribe - just ran into this problem...
Comment #4
fmjrey CreditAttribution: fmjrey commentedI just upgraded from 6.x-1.0-alpha6 to alpha7.
Here's my proposed patch alpha7 (equivalent to patch from #2)
Comment #5
sgabe CreditAttribution: sgabe commentedCommitted to both branches.