I have a theme inheritance problem:
I've got Fusion Core 2.x with a subtheme (let's call it dave) - (it is actually called dave). And then a subtheme of dave called andy (it was late at night). andy has nothing but an info file - he only exists so I can easily assign a different logo and block layout to some pages. Themes are switched based on path. I'm also using Fusion Accelerator.
However, andy's settings aren't being respected when the theme triggers. See helpful diagram.
If you could offer some help so that andy can express himself, I'd be really pleased. :)
Comments
Comment #1
mshepherd commentedMore insight:
If I set
andyas my default theme, his settings prevail anddave's are ignored.So it seems that fusion apply settings are taken from the default theme and override the other theme (whether that be a sub theme or a sub sub theme)
Is this likely to be an inheritance issue or a problem with my switching mechanism? I'm using themekey.module.
Matthew
Comment #2
mshepherd commentedFurthermore, theme settings of the sub theme and sub sub theme are respected. It's only fusion accelerator (skin) settings that aren't respected.
Matthew
Comment #3
mshepherd commentedI just created a 3rd theme. A clone of
dave, calledmatthew. So he's a sub theme of fusion core.And I get the same behaviour as above. The fusion accelerator settings of the default theme are respected, the other settings are ignored.
Comment #4
mshepherd commentedI think I've ruled out Themekey causing the problem. Instead I'm using a custom module and hook_custom_theme().
I get exactly the same problem.
Comment #5
mshepherd commentedAnd my last on the subject for now:
While this would get shaky with more than one visitor at once and certainly when I turn caching on, it does demonstrate a point I was making at #1.
Here, the behaviour is as expected.
Comment #6
mshepherd commentedmoving to fusion accelerator
Comment #7
mshepherd commentedYes, this seems to be a problem in Fusion Apply rather than Accelerator.
fusion_apply_current_theme() in fusion_apply.module is always returning the default theme. I'll look into it further in the morning. If I can fix, I'll provide a patch.
Comment #8
aquariumtap commentedSkin plugins are inherited from parents, meaning both dave and andy will receive all of the skins made available by Fusion, and andy will receive all of the skins from dave. For example, all of those themes can set a grid width, because Fusion provides skin plugins to set them. The application of skins, however, is not subject to inheritance. So if you assign a block 3 units in dave's theme, it will have no effect on skin's theme.
Comment #9
aquariumtap commentedThe mic Andy needs to express himself might be Context or Panels. Have you experimented with either of those modules?
Comment #10
mshepherd commentedI'm confused by this.
I realise this isn't to do wth inheritance, but it seemed that way at first, when I thought it was a theme/sub-theme problem.
However, the current behaviour is that fusion apply skins only seem to apply to the default theme, regardless of what the current active theme. Drupal (#4 above) and many contrib modules (eg. themekey) provide a mechanism to change the active theme, and given that fusion apply provides a mechanism to select a skin per theme, I think it should respect the active theme. In #7 above I pointed out that my experience was that fusion_apply_current_theme() always returns the default theme, not the current active theme as may have been set by hook_custom_theme(). Is that intended behaviour?
Comment #11
mshepherd commentedyes, I've often used both panels and context, especially the latter.
Comment #12
mshepherd commentedThis seems to be the same issue as #682588: Skinr does not work when $custom_theme is set
Comment #13
sheena_d commented@mshepherd:
I think you got a bit too verbose in your bug description and caused us a bit of confusion on what the actual issue is. Just to clarify:
1. You are able to set Skins for each generation of theme.
2. Skins are properly applied to the default theme, regardless of whether it is a sub-theme or sub-sub-theme.
3. Skins are not properly applied to themes if they are active because of a 3rd-party module (i.e. Themekey or custom module using hook_custom_theme to switch the active theme from the default).
4. Do you happen to be using Dave or Andy as your admin theme?
Also, it would be helpful if you could check the weight of fusion_apply versus the module that is switching your theme. You can use phpMyAdmin to take a look at this in the System table. Here is a screenshot:
https://skitch.com/sheenad/gfn6m/fusion-apply-weight
If fusion_apply is a lower weight, or if they are the same weight and the other module's name comes after fusion_apply alphabetically, then the issue might be that the theme is not being switched until after fusion_apply has already decided which Skins apply to the current theme.
Could you also test to see if choosing a non-default theme in your User settings works correctly or not?
@aquariumtap - it sounds to me like Fusion Apply is returning the Skin settings for the default theme even when a 3rd-party's functionality is serving up a different theme from the default. Technically, $theme_key should always return the active theme, but fusion_apply_current_theme() attempts to avoid returning the Admin theme, so there is a chance that function is not working properly for a situation where a 3rd-party module is setting the theme. Another theory is that Fusion Apply is simply weighted lower than the module changing the theme and thus the Skins are being generated before the theme has been switched.
Comment #14
mshepherd commented@sheena_d Thanks. I'll look into the rest of your post later, but just to confirm that I've already experimented with module weight and it made no difference.
Comment #15
mshepherd commentedIn answer to your other points:
I tested module weights again. I set fusion_apply's weight to -10 and then 10, emptying the site cache after each change in weight.
The module weight made no difference.
As far as I'm aware, selecting themes per user is no longer available in Drupal 7 core. If I'm wrong on that, let me know & I'll check it out as you asked.
Comment #16
sheena_d commented@mshepherd - Thanks for all your thorough testing!
Now, my best guess is that fusion_apply_current_theme() is returning an incorrect result when a 3rd-party is changing the active theme.
Lines 676-679 of fusion_apply.module are my best guess as to the cause of this issue:
Comment #17
aquariumtap commentedUpdating title to be about $custom_theme, not inheritance. Side note: currently there are unit tests for inheritance, but not for $custom_theme. Need to add.
Comment #18
aquariumtap commentedThe global variable $custom_theme is no longer in use. It has been replaced by menu_get_custom_theme(). I've filed an issue with the core docs team. I'll work on an Accelerator patch.
Comment #19
mshepherd commented@aquariumtap - That makes sense. Thanks.
Comment #20
aquariumtap commentedHere's a patch. I should write a test as well.
Comment #21
sheena_d commentedTested and works great. Thanks!
EDIT: I should elaborate:
I installed the ThemeKey module and set up a rule to serve Fusion Starter for one node page and use a custom Fusion sub-theme as the default theme. I assigned different skins to one block on that page to each Fusion Starter and my custom Fusion sub-theme.
I confirmed that the issue exists - the skin assigned for my custom sub-theme persisted even when Fusion Started was served by the ThemeKey module.
Then, I applied the patch and cleared site cache. Now, the appropriate skin is being displayed for the page using the Fusion Starter theme.
I did not encounter any warning message or odd behavior.
Comment #22
aquariumtap commentedCommitted.
Comment #23
mshepherd commentedGreat work! Many thanks - I'll test it out in the morning & report back, but it sounds like it's sorted. :)
Comment #24
mshepherd commentedYes, sorted. Thanks