Is it possible to remove the module/system/default.css file. I'd like to do this in the .module file and not in the template.php file.
My goal is to disable this style in my drupal website without manipulating a template/theme.
Is it possible?
Thanks in advance,
Bat
This is possible. You can use template_preprocess_page in your custom module to whack Drupal's default CSS:
function mymodule_preprocess_page(&$vars) {
// Get CSS array and remove selected stylesheets
$css = drupal_add_css();
unset($css['all']['module']['modules/system/defaults.css']);
// Override Drupal styles
$vars['styles'] = drupal_get_css($css);
}
Because of Drupal's architecture, you'll almost certainly need to set the module weight to something greater than your other installed modules to ensure that your preprocessor runs last and no other module will be adding CSS.
Related
I have a small problem with Shopware aplication. My point is, I create a new Theme which works perfectly, I can change any information at webpage using shopware backend profile, but when i copy the less files to my new repository folder, I cannot compile new theme. It stucks.
From the beginning,
Creating a theme using parent Responsive, all works perfect, theme compile.
Changing information on page, work perfect, theme compile.
Copy less files from Responsive/_public/less to newrepository/frontend/_public/less etc and it stucks.
Right now i dont have any idea how I am suppose to deal with it.
Any ideas ?
When a theme in shopware doesn't compile there is most probably something wrong with your less files. Have you copied all less files?
The path you mentioned is not correct.
syntax error in less files?
Did you copy the file Responsive/frontend/_public/src/less/all.less without copying the files that are imported in the all.less? Same applies for other files in this directory.
Whatever it is that is wrong with your less files. You shouldn't need to copy them from the parent theme. If you want to change something, just create your own files.
Say you want to have the background white. Create a file YOUR_THEME/frontend/_public/src/less/_modules/body.less with the content:
body {
background: #fff;
}
Then you are also going to need a file YOUR_THEME/frontend/_public/src/less/all.less with the content:
#import "_modules/body";
No need to copy or modify the original files.
Create a .css file here:
Responsive/frontend/_public/src/css/style.css
After that you should include the file in your Theme.php file like this:
protected $css = array('src/css/style.css');
under this function:
public function createConfig(Form\Container\TabContainer $container)
{
}
It worked for me. I have no idea how to include less files in a theme, they are usually added in a plugin by creating an event. I hope this helps.
Also Responsive Theme is default theme in Shopware. You should extend it and work on the newly created theme.
I guess it is obviously but are you following the Shopware strukture?
all.less (#import "modules";)
--_modules (#import "_modules/your";)
---your.less
?
Please don't copy all Less Files from the responsive theme. There are some mixins for the grid that stucks if you compile it twice, which is exactly the case if you copy all the files.
I use the following code to load YUI modules.
YUI().use('tabview', 'datatable', 'datasource-local', 'node', 'node-load', function(Y)
{
......
});
This would load the modules and ALL of the respective CSS files.
But I want to use the CSS selectively. Let's say I don't want to load CSS for TabView.
How can I achieve that?
I tried the following -
YUI({ fetchCSS: false }).use('tabview', 'datatable', 'datasource-local', 'node', 'node-load', function (Y)
{
......
});
Its obvious that the above code would not load CSS files for any module.
How can I disable CSS for tabview so that I can use my own?
There is 'override' property in the skin config. That allows you to use differents skin for some modules.
You may create a skin with your own css file, and tell the loader to use this skin for the module you want (tabview in your example).
I'm not sure you can have different source folder for the differents skins though.
http://yuilibrary.com/yui/docs/api/classes/config.html#property_skin
You can also try to define a css module and 'use' it.
http://yuilibrary.com/yui/docs/api/classes/config.html#property_modules
I hope it helps you!
I need to theme my lightbox. I can see the HTML generated by the JavaScript code in lightbox.js, but I cannot overwrite that file, or I will lose my changes when I update the module. Is there any better way to override a theme output?
You didn't report for which Drupal version you are interested; the answer I am giving is valid for Drupal 6, but few things would change for Drupal 7.
Lightbox2 uses a template file for its output. If you create a custom module that implements hook_theme_registry_alter() to use a different template file, then you can use a template file that uses a JavaScript file you wrote.
can you not theme it just by changing the CSS?
In your theme's .info file you can override the module's css and/or js and then you copy the css or js file from the module into your own theme folder, (every theme should have a .info, if not create one) - this means you don't touch the actual contrib modules files
Drupal will then use the one from your theme, which you can edit to your hearts content, and if you do hit problems you just remove the entry from the .info file and it will then go back to using the original module filea.
I haven't done it for JS but I believe the process is the same as for CSS and here is a snippet of what's in my .info file - btw I think once you use this method of overriding you have to declare the default style.css too
stylesheets[all][] = style.css
stylesheets[all][] = lightbox.css
Update:
It's only possible to use the .info file to override JS in D7, but there is module JSAlter which might help with D6
I am trying to organize my theme folder, which has node theming overrides for dozens of views. Basically I have two different styles and I want them all to look the same, more or less.
Is there a way in template.php that I can do this? And what is the best way?
I tried this code in my theme's hook_preprocess_node function:
switch($vars['view']->name) {
case 'taxonomy_term' :
switch($vars['view']->current_display) {
case 'page' :
array_push($vars['template_files'], 'list-view');
default :
break;
}
break;
default :
break;
}
And when I look in theme developer, I can see the list-view.tpl.php file there, but its not actually using that file from my theme directory. What am I missing?
As you can see in theme() Drupal will only actually use a template if it exists according to drupal_discover_template().
You should try to figure out if that is the case.
place some debug code in the theme() function in includes/theme.inc to see what drupal_discover_template() returns for vairious template calls.
Can it find it?
If not:
place some debug code in drupal_discover_template() to find out where Drupal thinks it no longer is a template.
My gut-feeling says that it is due to subdirectories where the template files reside, but which you have not added to the template_files variable: views/lists/some_list.tpl.php is not the same as some_list.tpl.php.
You need to rebuild the cache for the tpl.php file to be picked up.
Is there a place where I can place override theme files other than a theme's folder? For example, if I wanted to override the appearance of a view's row in the same style for more than one theme without having to use more than one file.
If there isn't a generic way to do this (for any theme file), is there a way to do it for a view's theme files?
In your module, you can use hook_theme to declare a theme function or template for your view's row. This way, your single template will be used by all your themes without any special code in them. See the Theming your views in your module section in the Views's API Advanced Help page.
You could include an include_once type statement in your tpl.php file and just import the code from where ever. This way you have any number of files that refer to one.
It is not recommended though since if you move your theme folder or rename anything this can be harder. Also if you put your theme in another site you need to keep track of all of these off-theme hacks.
I think views seeks tpls inside of the theme folder. It's be nice to have something like that though.