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

mshepherd’s picture

More insight:

If I set andy as my default theme, his settings prevail and dave'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

mshepherd’s picture

Furthermore, theme settings of the sub theme and sub sub theme are respected. It's only fusion accelerator (skin) settings that aren't respected.

Matthew

mshepherd’s picture

I just created a 3rd theme. A clone of dave, called matthew. 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.

mshepherd’s picture

I think I've ruled out Themekey causing the problem. Instead I'm using a custom module and hook_custom_theme().

function MYMODULE_custom_theme() {
  if (!drupal_is_front_page()) {
    return 'andy';
  }
}

I get exactly the same problem.

mshepherd’s picture

And 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.

function MYMODULE_init() {
  if (!drupal_is_front_page()) {
    variable_set('theme_default', 'andy');
  } else {
    variable_set('theme_default', 'dave');
  }
}

Here, the behaviour is as expected.

mshepherd’s picture

Project: Fusion » Fusion Accelerator
Version: 7.x-2.x-dev » 7.x-2.0-alpha1
Component: Miscellaneous » Code

moving to fusion accelerator

mshepherd’s picture

Yes, 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.

aquariumtap’s picture

Status: Active » Closed (works as designed)

Skin 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.

aquariumtap’s picture

The mic Andy needs to express himself might be Context or Panels. Have you experimented with either of those modules?

mshepherd’s picture

I'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?

mshepherd’s picture

yes, I've often used both panels and context, especially the latter.

mshepherd’s picture

sheena_d’s picture

Status: Closed (works as designed) » Postponed (maintainer needs more info)

@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.

mshepherd’s picture

@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.

mshepherd’s picture

Status: Postponed (maintainer needs more info) » Active

In answer to your other points:

  1. Skin settings correctly appear for all sub themes and sub sub themes. These are all correctly saved.
  2. Skins are correctly applied to default themes whether these are sub themes or sub sub themes
  3. If a 3rd party module changes the theme from default, the skin applied is that of the default theme, not the currently active theme.
  4. Neither dave nor andy are used as admin themes.

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.

update system set weight=-10 where name="fusion_apply";
update system set weight=10 where name="fusion_apply";

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.

sheena_d’s picture

Assigned: Unassigned » aquariumtap

@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:

  elseif (!empty($custom_theme) && drupal_theme_access($custom_theme) && !($exclude_admin_theme && $custom_theme == variable_get('admin_theme', '0'))) {
    // Don't return the admin theme if we're editing Fusion Apply settings.
    $current_theme = $custom_theme;
  }
aquariumtap’s picture

Title: Inheritance of fusion accelerator settings between a sub theme and a sub sub theme » $custom_theme not being recognized

Updating 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.

aquariumtap’s picture

The 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.

mshepherd’s picture

@aquariumtap - That makes sense. Thanks.

aquariumtap’s picture

Status: Active » Needs review
StatusFileSize
new942 bytes

Here's a patch. I should write a test as well.

sheena_d’s picture

Status: Needs review » Reviewed & tested by the community

Tested 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.

aquariumtap’s picture

Status: Reviewed & tested by the community » Closed (fixed)

Committed.

mshepherd’s picture

Great work! Many thanks - I'll test it out in the morning & report back, but it sounds like it's sorted. :)

mshepherd’s picture

Yes, sorted. Thanks