This patch fixes a number of problems:
* makes the path_to_theme() function useful again by prepending base_path() (moderate problem -- only affects some contrib themes)
* fixes some issues with indenting and comment accuracy in includes/theme.inc (very minor)
* allows users to reset their theme to the site default (major bug -- can cause significant confusion for site admin)
* on user theme selection page, adds note by the site-default theme (minor usability improvement)
* corrects stylesheet inclusion order in chameleon theme... common.css should not be included with theme_add_style (somewhat significant problem -- breaks chameleon theme layout as well as any user-created styles based upon it)
Please review and commit before final 4.7 release.
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | fix_theme_regressions_20060307.patch | 4.79 KB | TDobes |
| #1 | fix_theme_regressions_20060305b.patch | 4.82 KB | TDobes |
| fix_theme_regressions_20060305.patch | 5 KB | TDobes |
Comments
Comment #1
TDobes commentedOops -- sorry... made a mistake.
I just noticed that phptemplate is using path_to_theme now... so changing it breaks other things.
Attached is the same path, but with the path_to_theme changes removed. Contrib themes will just have to add a base_path() to all their path_to_theme calls, I guess.
Sorry for the noise.
Comment #2
TDobes commentedchanges are very minor -- but important. Please review/commit.
Comment #3
dries commentedWhy is theme_add_style broken (change to chameleon)? And if it can't be used, is it still useful? Right now, it is an API. If modules/themes aren't supposed to use it, that should be changed.
I also noticed that there exists a 'theme_stylesheet_import':
The difference between theme_add_style and theme_stylesheet_import is confusing at best. Could you poke this some more TDobes? That would be much appreciated.
Comment #4
TDobes commentedI actually think this needs better documentation, but I'm not sure where to place it.
theme_add_style and theme_get_styles were added shortly after the big theme patch landed to solve the problem of referencing stylesheets in the proper order. At that time, we only had drupal_set_html_head available to us. We needed to reference drupal.css (which comes from drupal_set_html_head / drupal_get_html_head), common.css (which is part of chameleon), then style.css (which is style-specific)... but it was important that they were referenced in the order I just listed. The solution (which I credit to Steven) was theme_add_style. theme_add_style is for use by the theme system for including style-specific CSS. It can also be used by end-users on PHP pages (or perhaps by a yet-to-be-written "custom user-created stylesheet" module) for including CSS only on certain pages within the site.
Modules, on the other hand, should not be using theme_add_style because situations can develop in which themers cannot override module-specific CSS. (module CSS should be referenced BEFORE all theme CSS) For this reason, modules should use drupal_set_html_head instead.
The problem in the chameleon theme is that it's specifying to theme_add_style to reference the common.css file in the chameleon_page function. By the time we run that function, we've already executed init_theme, which is where style.css gets passed to theme_add_style. The styles are them returned (by theme_get_styles) in that order, which is the opposite of what most themers are going to expect. Style-specific CSS should be last. (unless followed by page-specific CSS, which is why theme_add_style can be used in PHP pages)
theme_stylesheet_import is used to generate the HTML necessary to reference a style. We could use it in chameleon.theme if we wanted. I actually didn't use it because I forgot about it. I've attached a new patch which uses theme_stylesheet_import instead of a link tag.
Please let me know if any of this is unclear; it's quite late here, so my explanation may end up being a bit confusing.
Comment #5
TDobes commentedTo clarify:
So this is the order we end up with:
1. drupal.css
2. module CSS (i.e. event.css from event.module)
3. theme CSS (i.e. common.css from chameleon)
4. style CSS (style.css files from any theme)
5. user CSS (something page-specific)
Stylesheets can override rules applied in any CSS which precedes them. (i.e. style CSS can override everything else, except for user CSS)
Comment #6
dries commentedAmazing follow-up! Thanks TDobes. The code looks good now so I committed your patch.
Comment #7
(not verified) commented