How should I do to make CSS3 changes in a subtheme?

Comments

menlo624’s picture

I do have exactly the same question. I'd love to modify the css3 style sheets, but just cannot make it work.
Otherwize, great style! Thanks

jdub110’s picture

I am also struggling with the same issue. I want to change the colors of the menu tabs.

Lioz’s picture

Assigned: Unassigned » Lioz

have you tried to copy the css3 folder of the main theme and paste it in you /css subtheme folder?
you should be able to edit those files and modify subtheme's css3 styles.

Let me know if it works.

jdub110’s picture

I tried to do that, but there is some code in the template.php file that loads the css3 style sheets on the fly if that setting is set in the theme config. I tried to make my own copy of the template.php in my subtheme, but couldn't get it to work. I'm a drupal noob, so I'm probably missing something simple.

Lioz’s picture

Version: 7.x-3.0-beta6 » 7.x-3.0-beta7
Status: Active » Reviewed & tested by the community

@jdub110 you are right, path_to_theme() seems to point the base theme not the active subtheme

try to replace the html preprocess function in template.php with this code

function marinelli_preprocess_html(&$vars){

  // we set to path to the active theme (valid also for subtheme)		
  global $theme_key;
  $path_to_theme = drupal_get_path('theme', $theme_key);
  
  // CSS3 effects: load modernizer and the stylesheets
  $css_typo = theme_get_setting('css_typo');

  if (theme_get_setting('css') == 1) {
    drupal_add_js(path_to_theme() . '/js/modernizer/modernizr.js');
    drupal_add_css($path_to_theme . '/css/css3/css3.css', array('group' => CSS_THEME + 1,'every_page' =>TRUE));
    drupal_add_css($path_to_theme . '/css/css3/css3_graphics.css', array('group' => CSS_THEME + 2,'every_page' =>TRUE));
    if ($css_typo == 2) {
      drupal_add_css($path_to_theme . '/css/css3/css3_fonts.css', array('group' => CSS_THEME + 3,'every_page' =>TRUE));
    }
  }

  // Send a js variable to tell topregion js not to hide the region
  if (arg(2)=="block" && arg(3)=="demo") {
    drupal_add_js(
      array(
        'marinelli' => array(
          'blockdemo'  => TRUE
        )
      ),
      array('type' => 'setting')
    );
  }
}

Let me know if it works!

jdub110’s picture

Thanks so much for your help!! I think I have it all working now!!!

I did have to make one minor change from what you suggested...
I changed drupal_add_js(path_to_theme() to
drupal_add_js($path_to_theme and copied the js dirs and file into my subtheme folder.

Thanks again!

Lioz’s picture

@jdub110 I think it's not necessary to change the js path since it can be linked from the base theme. It should work without your change, let me know.

jdub110’s picture

@Lioz I changed it back to your original code and you were correct it works. When I was trying to get this working, I had introduced an error into the .css file that stopped things from working, and I misdiagnosed the problem.
Thanks again for your help!

Lioz’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

manicolaus’s picture

The current download (7.x-3.0-beta9) incorporates the updated code Lioz posted Feb. 11 above. But I found by experiment that it is also necessary to copy the css folder from the main theme to the subtheme folder in order to make the css3 effects work.

mattez’s picture

Status: Closed (fixed) » Active

Confirmed. 3D effects will begin work only after copying directory "css3" into mysubtheme/css/. I'm not a programmer, but it seems that the variable "$ path_to_theme" returning path of subtheme.

I changed this "drupal_add_css($path_to_theme ..." to "drupal_add_css(path_to_theme() ..."
And It works without copying folder!

danepowell’s picture

Version: 7.x-3.0-beta7 » 7.x-3.0-beta11

It seems that the problem has flipped from one of not being able to override css3 in a subtheme, to being forced to override css3. This breaks Drupal theming standards- css files should always be automatically inherited from a base theme. FYI, the same problem now exists for reset.css in beta11.