Posted by Mark123 on November 8, 2011 at 5:55pm
13 followers
Jump to:
| Project: | Features |
| Version: | 7.x-1.0-beta6 |
| Component: | Code |
| Category: | bug report |
| Priority: | major |
| Assigned: | Unassigned |
| Status: | active |
Issue Summary
Newbie to Features question:
I am trying to add the CSS for the items in a Feature with a stylesheet specified in the .info file:
stylesheets[all][] = "stylesheet.css"
After moving the relevant CSS into that file, I recreated the Feature (don't know if this step is necessary), but the CSS didn't take effect. I tried a full path name for the CSS file as well.
Any advice on to whether/how this works?
Comments
#1
What do you mean when you say "the CSS didn't take effect"?
Can you elaborate on what was happening before you recreated the feature and what is now happening after the recreate.
#2
That there's no CSS styling--it appears the stylesheet is not getting loaded.
What I did was take the CSS out of my big main stylesheet, and put it in a stylesheet as described above. I did this because I thought it would be better to keep the styles for the feature together with the feature.
So, once I took the CSS out of the main stylesheet, the items in the feature were not getting styled. After creating the stylesheet as described above, modifying the .info file and recreating the feature, it was the same--the items in the feature are not getting styled.
#3
Unless I'm off my rocker, modules don't include stylesheets based on that being in the .info file, and if it did, there are many cases where you wouldn't really want it to just load the CSS on *every page*. Good practice is to apply some kind of logic to only load it when needed.
#4
I don't know about D6, but it's OK in D7--from http://drupal.org/node/542202:
Drupal 7 allows you to add CSS files in the module's .info file if it should be added on every page, just like theme .info files do. Here is an example from the node module's .info file:
stylesheets[all][] = node.cssI believe there's also the school of thought that since Drupal can consolidate all the CSS files into one file, it's better to just load one big stylesheet.
So the reason for using the Feature-specific stylesheet is more organizational--just to keep all the relevant code together. It would also make it easier and cleaner for using Features for syncing Dev-Staging-Production.
#5
Okay, I believe all that you said.
Features are just normal modules however. There is nothing about it that should prevent you from adding a stylesheet reference to the .info file and having it load. If a couple cache clears and a file permissions check don't clear it up, this is a mystery.
#6
I'm thinking the same thing as you in #5. Thanks for taking the time to look at it. At least it's not a big problem--I'll just leave the CSS where I originally had it.
#7
Reopen if this turns out to still be an issue
#8
OK, thanks.
Just speculating here--Since Features are normal modules,
stylesheets[all][] = node.cssshould be expected to work if you converted a Feature to a (non-Features) Module.However, that doesn't necessarily mean that code in Features for 'Recreating' recognizes
stylesheets[all]. Might it be the case that there needs to be a code addition for D7 for pulling in stylesheets specified bystylesheets[all][] = node.css?#9
The only functionality specific to a Features Module and not a Normal module are (1) exported components that are defined in the .info file, and thus managed by Features for Updates and Reverts and (2) hooks invoked by Features that don't otherwise exist.
Anything else in a Features module, or in the .info file, is literally just a module. It's kind of like saying it's an OG module, if you happened to define some OG settings with stuff in the .info file instead of Drupal variables.
So anything you are seeing with a stylesheet definition should be the same as in any module, unless some Features-related module has a bug and is over-mucking about with .info file contents.
#10
Yep it is actually...
I've tested this twice now and it looks like when you add new things to your existing feature it rips out the other settings you have. In this case I had custom style sheets stuff in there that was removed.
How to repo:
* Create a feature
* Edit the info file and add your own stylesheet
* Add something new and it's removed
Now what's interesting is if you do a 'recreate' and don't add anything is re-orders the stylesheet to the bottom and generates everything properly.
#11
That needs confirmation. If features is scraping out other .info file infos that is a problem. Should be an unremarkable passthru.
#12
Hi,
I just recreated this bug
1. I created a feature of a view
2. I manually added a stylesheet to the info file
3. I did a features- update
4. I checked the info file and the style sheet line had disappeared.
I think features-update should maintain the style sheet in the info file even if we shouldn't be putting CSS in there.
Jaime.
#13
Confirming that this is an issue in the latest release. Steps to recreate:
stylesheets[all][] = myfeature.cssto the feature's .info file.Result: The stylesheet declaration is removed from the .info file on export.
I'm also taking the liberty of updating this issue's title and settings to be more descriptive of the bug.
#14
I'm unable to reproduce on 7.x-1.x...
$pwd/Users/joel/htdocs/openpublic_build/sites/all/modules/test_panels_permissions
$cat *.info
name = "test_panels_permissions"
core = "7.x"
package = "Features"
php = "5.2.4"
dependencies[] = "features"
dependencies[] = "panels"
features[user_permission][] = "administer panels styles"
features[user_permission][] = "use panels locks"
stylesheets[all][] = "test_panels_permissions.css"
$drush fu test_panels_permissions
Module appears to already exist in sites/all/modules/test_panels_permissions
Do you really want to continue? (y/n): y
Created module: test_panels_permissions in sites/all/modules/test_panels_permissions [ok]
$cat *.info
name = "test_panels_permissions"
core = "7.x"
package = "Features"
php = "5.2.4"
dependencies[] = "features"
dependencies[] = "panels"
features[user_permission][] = "administer panels styles"
features[user_permission][] = "use panels locks"
stylesheets[all][] = "test_panels_permissions.css"
$
#15
My guess is that this issue is from UI only.
My other guess this will be solved by making the UI more like the drush command.
#16
I have wondered if it was worth the madness to try putting together a Drush interpreter for Form arrays. Anyway, back to reality ;)
#17
For what it's worth I didn't place this at the bottom of the file but actually somewhere in between. This could just be a UI coding issue who knows.
#18
I can confirm this problem.
When I update the feature with drush, everything is fine. When I update the feature over the UI, the styles and scripts are removed/lost.
#19
+1 to #18
#20
Same issue. I found the same as #18 true.