Closed (outdated)
Project:
Skinr
Version:
7.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
30 Apr 2012 at 09:11 UTC
Updated:
20 Oct 2025 at 08:22 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
moonray commentedInheritance from the parent theme should be automatic (the skin files get automatically included). It won't automatically enable the skins, though. You might have to add a hook_skinr_skin_info_alter() in your theme's *.skinr.inc file to change the skins' statuses to enabled (or disabled) for your sub-theme.
Example:
Comment #2
mrfelton commentedAll of the skins are already available to use in my base theme. It's the actual applied skin styles that are not being inherited.
For example, I set the default theme to my_base_theme, and configure a load of skinr styles for various elements on my site. I'm using the SwitchTheme module to allow users to switch the theme to one of several subthemes, where things like colours and background images are changed. When the theme is switched, none of the blocks etc have the skinr styles applied. I can edit them manually and add them for each specific subtheme - but I want them to inherit them automatically.
Comment #3
moonray commentedThat's not within the scope of Skinr.
You can probably get the effect you're looking for by doing some magic in a custom module using hook_skinr_preprocess_alter()
Comment #4
mrfelton commentedSeems like a pretty common thing to want to do. In my experience Sub themes (I'm talking about theme variations - not base theme subthemes) would generally only override a small amount of styles. We have hundreds of skinr styles set on our main theme, and don't want to override any of these in the the various subthemes.
Why would that not be in the scope of Skinr? Sounds like a pretty useful option to have.
Comment #5
mrfelton commentedI have this semi-working in a custom module, however, there is a problem with Skinr that's stopping me from being able to do what I need to do. The code below works, but only for elements where at least one skinr attribute has been set on the subtheme. The problem seems to be that you only actually call skinr_preprocess_alter on elements that have some skinr properties set. That would generally make sense, but for this use case it doesn't as the active theme won't have any/many skinr settings on any elements.
Comment #6
mrfelton commentedI can't see a viable way to do this using the prepress_alter function. I can't really see a good reason why this would be out of scope in Skinr, so here is a patch that adds style inheritance support to Skinr, enabling the use of a
skinr[options][inherit_styles] = truesetting, which will allow applied styles to be inherited from the base theme.Comment #7
moonray commentedskinr[options][inherit_skins] = truewas used in Skinr 6.x-1.x and 6.x-2.x to do what I described above: make skins in the base theme available. Not to automatically apply skins from the base theme to the sub theme.You can achieve your goals by duplicating loading the skins for your base theme in hook_skinr_preprocess_alter() and adding those to the $skins array.
Note, this code wasn't tested:
Comment #8
mrfelton commentedskinr[options][inherit_skins] = truewas used for that - that's why I names thisinherit_styles, as we are talking about inheriting applied styles, not defined skins. I haven't tested your code above, but it's a similar approach to what I was trying initially in preprocess. But, it wont work because preprocess only gets called for elements that have at least one style applied in the current theme.Comment #9
moonray commentedYou're right about this approach not working.
Your other option is to duplicate the skinr_preprocessor function as mymodule_preprocess, and then add only the base module skin settings, and not the current theme's skin settings (which will be added by skinr_preprocess, still). Since it just adds classes to the classes_arrray it should be stackable.
Another option is to hijack skinr_preprocess by removing it from the list using hook_theme_registry_alter() and using you own version; this would prevent duplicate code from being run.
As for the option... this is excerpted from the Skinr docs (it's not about applied skins, but enabled skins):
Inheriting Skinr styles from a base theme
If you are creating a subtheme and the base theme you are using contains it's own Skinr styles, Skinr allows you to choose whether or not you want your subtheme to inherit those skins or not. By default Skinr will NOT inherit skins. If you want to be able to use a base theme's skins, you will need to add this line to your .info file.
skinr[options][inherit_skins] = trueComment #10
mrfelton commentedYes - thought about the other preprocess approach too - but seems like it would add a fair amount of duplication.
I'm not really clear why we are bringing inherit_skins into this discussion. inherit_skins is about inheriting defined skins, and was a D6 thing which is included in D7 in a slightly different way (you implement a hook to modify the behavior rather than add an option to the theme's .info file). This issue is about something completely different (although when I first opened the ticket I had thought that the answer lay in inherit_skins). This is about inheriting styles, hence I have used a different name for the 'inherit_styles' .info option.
Are you still of the opinion that this doesn't belong in Skinr core? And if so, why not? Seems like a pretty useful addition. Skinr already has the ability to inherit skins. Why not allow it to inherit applied styles too? Sorry if I'm missing the point on this one.
Comment #11
moonray commented@mrfelton Sorry about rehashing the
inherit_skinsthing. I thought we were still on that. :-)As for allowing the inheritance of Skinr settings (that's what they're called in code)... I'm waiting for some feedback from @jacine on this.
My main issue with this is the added overhead, and the fact that it takes away from the modularity that skin plugins provide since version 7.x.
Comment #12
mrfelton commented@moonray - I don't think there is much in the way of overhead here. We call skinr_implements_api() to find out if 'Skinr settings' inheritance is enabled, and the skinr_implements_api() function uses a static cache. So all we are talking about is looking at the value of an already statically cached variable.
How does this take away from the modularity that skin plugins provide?
Comment #13
mrfelton commentedSetting back to needs review, as I don't know what further work is required.
Comment #14
moonray commentedAttached patch ensure
hook_skinr_preprocess_alter()is called regardless of whether or not skin configurations are found for the element in question.This should allow custom modules to inject skin configurations.
Inheriting skin configuration from parent themes is an edge case. Enabling this might horribly break people's existing sites that aren't expecting that behavior.
So, I think with the above fix in place it should allow extending Skinr with a custom module to inject skin configuration and solve your problem while not breaking the site for 99% of use cases.
The code snippet in #5 should now be possible.
Comment #15
mrfelton commentedI don't really see how skin inheritance is an edge case. Themes have inheritance. Skins relate to themes, and so should have an inheritance option too. It makes no sense to require users to duplicate every single Skin configuration out to every single subtheme manually to make the base theme skin configurations available in subthemes too. Subthemes should be able to inherit skin configs just as they can other configs. It shouldn't need a module or custom code to do that. It should be an option in the theme settings, IMO.
Comment #17
moonray commented#14: skinr-preprocess_inject_skins-1554044-14.patch queued for re-testing.
Comment #18
moonray commentedI was under the impression that theme settings aren't inherited by sub themes. If theme settings aren't inherited, applied skin configurations should not be either.
Comment #20
mrfelton commentedYour logic makes little sense to me. Themes can be configured to inherit from a base theme. That means that they share all attributes of the base theme. That is configured by setting a theme setting. The theme setting itself is not inherited - it is explicitly set in the sub theme. IMO, the same should be true of skinr. It should be able to inherit from the base theme, if configured to do so in the theme settings, making the sub theme act just like the base theme.
All of the above help to reduce the need to duplicate countless amounts of duplication following the concept that a theme that inherits from a base theme should start out exactly like the parent theme, and should be able to extend that theme as simply as possible. Why should it not also be possible to inherit skinr configurations from a base theme? The reasoning I have heard so far includes:
> My main issue with this is the added overhead.
Where is the overhead? checking a statically cached variable from RAM hardly constitutes much in the way of overhead. Skinr has plenty of performance problems to be sure, but I don't think thats one of them.
> And the fact that it takes away from the modularity that skin plugins provide since version 7.x
How does letting people decide if the want their sub theme to inherit skinr applied styles from their base theme take away from the modularity that skin plugins provide?
> Inheriting skin configuration from parent themes is an edge case. Enabling this might horribly break people's existing sites that aren't expecting that behavior. So, I think with the above fix in place it should allow extending Skinr with a custom module to inject skin configuration and solve your problem while not breaking the site for 99% of use cases.
The setting would only affect users that explicitly enable it in their .info file - 99% of users would likely not do that, unless they all actually wanted style inheritance.
Comment #22
astonvictor commentedD7 reached its EOL back in January 2025, and there is no active release for D7 for this module anymore.
Development or support is not planned for D7. All D7-related issues are marked as outdated in a bunch.