Active
Project:
Wysiwyg
Version:
7.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
22 Apr 2013 at 12:56 UTC
Updated:
11 Apr 2014 at 20:23 UTC
Jump to comment: Most recent
Hello,
When adding a stylesheet for my editor, the path seems to be correct except that it use my primary url domain and not the current domain.
How can i afford it?
Thank you,
Damien.
Comments
Comment #1
twodWhat do you mean by "afford it"?
Do you mean the stylesheet used inside the editing area? It should use the current domain you're on, since it does not explicitly select a specific domain. Wysiwyg grabs the stylesheets added to the theme group using drupal_add_css(), unless you tell it to only use the default editor stylesheet or define your own files.
Which CSS settings are you using in your editor profile(s)?
Which editor are you using?
Which Drupal theme are you using (if you've set the profile to use the active theme's styles).
Comment #2
damien_dd commentedHi,
Sorry i hadn't see your answer.
Which CSS settings are you using in your editor profile(s)?
>> Define a css, with %b%t/css/wysiwyg.css
Which editor are you using?
>> CKE
Which Drupal theme are you using (if you've set the profile to use the active theme's styles).
>> Default
Comment #3
damien_dd commented>> What do you mean by "afford it"?
I want to use the css attached to my current theme and not to my principal domain theme (on multidomain install).
Comment #4
twodI have no idea what you mean by "principal domain theme", all multisite sites have their own individual theme settings as far as I know, and they never request anything from any other domain than their current one (the sites will in practice not know about any other multisite even existing).
Getting the "current" theme is a bit tricky in Drupal, especially when used in combination with the Overlay. Anything opening in the Overlay will think your admin theme is the current theme, despite a different theme being used when viewing nodes etc. Therefore we try to do the path substitutions like this:
%bgets replaced by the value of base_path().%tgets replaced by the value ofdrupal_get_path('theme', variable_get('theme_default', NULL)).Unless your sites area in subfolders of the domain, that should roughly translate to
/themes/bartikif you're using Bartik, or/sites/all/themes/mytheme/if you're using something else.CKEditor will take that path and put the current domain in front of it when performing requests inside the editing area. It gets the domain from the baseHref setting, which Wysiwyg sets to
$GLOBALS['base_url'] . '/'.Note: This part was accidentally removed from the latest Wysiwyg release, but is fixed in 7.x-2.x-dev. It not being there may confuse the editor about where the base folder is if JavaScript Aggregation is enabled in the Performance settings. Upgrade to 7.x-2.x-dev if you notice this issue.
In your example, with Bartik being the default in Drupal 7, you should be seeing requests to
http://yourdomain.com/themes/bartik/css/wysiwyg.css.If you want to request the stylesheets from a specific domain, you could maybe add the domain in front of the path like
http://yourotherdomain.com%b%t/css/wysiwyg.css, but I'm not sure that's what you're asking for.Comment #5
damien_dd commented>> If you want to request the stylesheets from a specific domain, you could maybe add the domain in front of the path like http://yourotherdomain.com%b%t/css/wysiwyg.css, but I'm not sure that's what you're asking for.
Problem is that this configuration is global and not by domains, so i have to put a general path like %b%t/css/wysiwyg.css
And the problem is this one:
I got 2 domains domainone.com and domaintwo.com, they use 2 different themes (themeone and themetwo). They share this config for wysiwyg css path %b%t/css/wysiwyg.css, but on both domain they use this path:
domainone.com/sites/all/themes/themeone/css/wysiwyg.css OK
domaintwo.com/sites/all/themes/themeone/css/wysiwyg.css Not OK
i want this path for the domaintwo:
domaintwo.com/sites/all/themes/themetwo/css/wysiwyg.css
Do you understand?
Despite this, thank for helping.
Damien.
Comment #6
twodNo Wysiwyg settings (or other Drupal settings) should be shared between domains in a multisite installation unless you use some tool to explicitly do that, like sharing database tables or using some sync module.
Sounds to me like both sites are set to use themeone as the admin theme? Not sure how %t oils end up the same on both sites otherwise.
You could try moving themeone to sites/domainone.com/themes/themeone (clear both site caches right after or things will get weird), domaintwo.com should have no access to it then.
Comment #7
damien_dd commented>> Sounds to me like both sites are set to use themeone as the admin theme?
themeone is not a admin theme, i use the admin theme as overlay, so i don't know how it ends up with it.
Maybe you're right, i might try separating the thme folder by subfolding domains.
Comment #8
BarisW commentedI'm having the same issue.
When using the domain module, one can set a different theme per domain.
In my case, I have two domains with theme1 and theme2.
For content editing, I use Seven. In the WYSIWYG settings, I've entered
%b%t/styles/wysiwyg.css. I'm expecting this to result in /sites/all/themes/theme1/styles/wysiwyg.css when editing content on domain1 and /sites/all/themes/theme2/styles/wysiwyg.css when editing content on the other domain.I see that the WYSIWYG changes the theme with this line of code:
So it used
<?php variable_get('theme_default') ?>which should be fine. Let's move this issue to the Domain thread, as I think it belongs there.Comment #9
BarisW commentedBetter title and Component
Comment #10
agentrickardI think the problem is that variable_get('theme_default') is returning the wrong value. Please verify.
That could happen if:
* WYSIWYG runs before Domain Theme.
* Domain Theme isn't settings that value. (Which apparently it is not, because that would violate how hook_custom_theme() is defined.)
The problem here, actually, is that calling 'default_theme' seems to be unreliable. It does not account for hook_custom_theme(). See drupal_theme_initialize() for the gory details.
The same problem should appear if a menu item declares a custom theme.
The proper fix may be to call the $theme global instead of the variable_get. I say that because of the core logic here:
That is, theme_default is not a reliable way to read the active theme for a page.
Comment #11
BarisW commentedAnother problem is that we don't need the current theme. This is mostly Seven, and we need to use the front-end theme in the back-end WYSIWYG.
What if WYSIWYG uses a piece of code like this to fetch the current theme instead of relying on variable_get alone?
Then Domain Access could implement
Comment #12
agentrickardWell, I'd like to avoid that, because it's module specific and therefore brittle. Besides, any other module that implements hook_custom_theme() will do the same.
I think the only way to retrieve the current theme is from the global $theme.
Comment #13
BarisW commentedBut isn't
global $themereturning Seven when we are in the admin interface? That's not what we want, as the WYSIWYG should use the front-end theme.Comment #14
agentrickardUgh. Perhaps, then, I should set $conf['theme_default'], but I'm afraid that might confuse other modules. We've had similar issues with Features and Display Suite.
Comment #15
BarisW commentedSo, should we set this back to the Domain Access module then?
Comment #16
agentrickardNo. I think you can do this in WYSIWYG module. That will let the module mirro what core is doing without having to ask other modules to handle a special case.
menu_get_custom_theme() static caches, so the performance penalty is minimal.
Comment #17
BarisW commentedHi Ken,
I've tried the approach you suggest but it doesn't seem to work. The theme that is returned by this function is 'seven' instead of the theme that is used on the current domain. Any other suggestions?
Comment #18
hermes_costell commentedI had this same issue and created a workaround. It's hackey enough that I think it should be its own module, but for the time being here's the idea:
My environment:
Drupal 7.x
Domain Access 7.x-3.10
WYSIWYG 7.x-2.2+33-dev
2 domains
each with their own separate theme
I moved the theme style sheets into the same directory heirarchy (/sites/all/themes/THEME_NAME/css/global.css) to try and resolve the above issue, but didn't work. For the purposes of this fix though I kept them in that spot.
In a custom module I had already built I added the workaround functionality in this way:
Then for the WYSIWYG profile edit page in the CSS input I chose:
Important: as mentioned above I had moved both themes' css files to the ../css/global.css in their base theme folder for the above to work. I have ideas about how to get around this, and furthermore expand this functionality to include multiple style sheets, but for the moment this works.
Also important - this mechanism will load the WYSIWYG style sheet based on the current URL in the browser window and what domain that maps to in the Drupal system - it will not look for which domain the currently edited item is published to in order to load that appropriate style sheet.