Hey, I'm a newbie front-end developer and I'm bad at PHP, so I have no idea what's happening here.

I included my stylesheet in my theme .info. The Module is picking it up, and outputting a CSS file -- but the CSS file isn't being processed by CSSCaffold. It's just the raw text from the CSS file (so @grid and all my constants are still right in there).

I followed your directions -- I downloaded your module, put the "scaffold" folder into it from the github repo you mentioned, and then installed it to my drupal site.

Any ideas why my files might be going through, but aren't being properly processed?

Thanks for your time and awesome work on this module!
Brian

Comments

jide’s picture

Category: bug » support

@brino,

Things to verify :

- Have you included the stylesheet file using scaffold[all][] syntax ?
- Have you tried with a minimal stylesheet to ensure it has no parsing error ?
- If it still does not work, you may want to manually fill the Document root value in admin/settings/scaffold.

You may also try the dev version since it has some bugfixes.

brino’s picture

Thanks for the response!

1. Yes, I tried scaffold[screen][], scaffold[print][], and scaffold[all][]. The
tag is being generated to the page, but the stylesheet is just the normal CSS, not preprocesed.

2. A normal stylesheet is going through fine, unprocessed by scaffold.

3. I'll play with the doc root a bit more, although it seemed to be correct in the settings.

I'll also give the dev version a shot!

Thanks for taking the time to respond, I really appreciate it!
Brian

brino’s picture

Hi Jide,

Thanks again for responding. I've tracked down the problem. Tao, my base theme, has a preprocess function which strips a lot of the core drupal styles from the page (which is awesome for typographic consistency), but is unfortunately breaking the Scaffold plugin.

I'm a decent JavaScript guy, but not much of a PHPer, so I'm not exactly sure how to resolve this conflict... I may have to finally try my hand at rewriting the preprocess function.

Brian

jide’s picture

That's an interesting issue, other themes may do the same, I'll see if this issue can at least have a workaround by tweaking the theme, and if so add instructions in the README.txt file.

brino’s picture

Awesome. I owe you a beer at the next DrupalCon in the states!

brino’s picture

Errr, nevermind! Just saw that you're French. I'll have to make it to Copenhagenthen =)

brino’s picture

And sorry to harass you about this, but I thought you might be interested in the following tidbit:

I've thought about switching to LESS, and thought I'd give the LESS module a shot. That module did in fact work with my Tao subtheme, so it may be helpful to review their implementation for a comparison.

Thanks,
Brian

jide’s picture

Hi brino,

Hey, thank you for the beer proposal, but yes, probably not in the US ;) Not even Copenhaguen, I won't be there neither, but some day maybe ;)

To track down the problem, could you tell me :

- What you do exactly ? Use Tao and modify it to add a scaffold stylesheet ? Use it as a base theme ?
- Could you use a very simple stylesheet, like this one :

@constants {
  test: #FF0000;
}
body {
  color: $test;
}

And see if the stylesheet is processed ?
- Ensure you checked "Development mode" and disabled Drupal css aggregation.

Flying Drupalist’s picture

I haven't tried this yet but I'm also using Tao so I'll subscribe.

jide’s picture

Status: Active » Postponed (maintainer needs more info)

Need more info for this.

razunter’s picture

Same problem with Zen2-based theme, Scaffold 2.2

jide’s picture

I quickly looked at the Tao template.php file, and the "styles" variable seems only affected for print stylesheet, so that's not the cause of the problem.

If you have the issue, please try with a modified Garland theme with the minimal stylesheet provided in my previous comment to see if the problem really comes from the theme.

bforchhammer’s picture

Subscribing... :)

dwillems’s picture

Building a new subtheme of tao and I'm having the same issue. Replaced my stylesheet with the minimal from #8 and still having trouble, switched base theme to garland and it worked fine. Anyone have info on a workaround until a real solution is found?

Josh Benner’s picture

I've recently built a subtheme of Rubik, which is itself a subtheme of Tao. To use with Scaffold I had to put this in my theme's template.php:

/**
 * Implementation of hook_preprocess_page().
 * 
 * This fires before Tao's implementation, so we can trap the special set of
 * styles that the Scaffold module prepared.
 */
function phptemplate_preprocess_page(&$vars) {
  if (preg_match('@^.*?/scaffold([^?"]+).*$@m', $vars['styles'], $matches)) {
    $scaffold_files = explode(',', $matches[1]);
    _mytheme_stash_scaffold_styles($matches[0], $scaffold_files);
  }
}

/**
 * Implementation of hook_preprocess_page().
 * 
 * This fires AFTER Tao's implementation, so we can restore our stashed styles.
 */
function mytheme_preprocess_page(&$vars) {
  list($scaffold_line, $scaffold_files) = _mytheme_stash_scaffold_styles();
  
  if ($scaffold_files) {
    $styles = $vars['styles'];
    foreach ($scaffold_files as $file) {
      $pat = '@^.*?'.$file.'.*$@m';
      $styles = preg_replace($pat, '', $styles);
    }
    $vars['styles'] = rtrim($styles) . "\n$scaffold_line\n";
  }
}

/**
 * Utility function to statically cache the scaffold files so we can fix the
 * styles after Tao mangles them.
 */
function _mytheme_stash_scaffold_styles($line = NULL, $files = NULL) {
  static $scaffold_files, $scaffold_line;
  
  if ($line && is_array($files)) {
    $scaffold_line = $line;
    $scaffold_files = $files;
  }
  
  return array($scaffold_line, $scaffold_files);
}

The offending code in Tao is found in tao_preprocess_page(), specifically where it replaces the styles with stuff it gets from tao_css_stripped().

Josh Benner’s picture

NOTE: My code in #15 does not work with CSS aggregation. I'll be tackling that eventually, though. ;)

Josh Benner’s picture

Okay, so in looking at this to share, I realized this can be so much easier. Put this in your theme:

function mytheme_preprocess_page(&$vars) {
  $vars['styles'] = _scaffold_get_css(tao_css_stripped());
}

This keeps Tao's CSS wrangling AND lets Scaffold process (and aggregate) its CSS files.

jide’s picture

Josh, thanks for the feedback, it will be useful to add to README.txt. And yes, indeed, the second snippet is much easier :)

razunter’s picture

But LESS has no problems with these themes.

gmclelland’s picture

FYI... I just created an Tao subtheme and everything seems to be working fine for me so far.

brino’s picture

Hey Glenn,

Yes! It looks like the newer version of Tao have actually gone away from a function that was stripping out the CSS aggressively, which caused my initial headaches. Plus, I'd like to note that I've solved another problem I had, where Scaffold was unable to require files properly, by fixing the base_path() for this module. If you have your drupal install in the document root, everything is cool. If not, and you're having problems with this module giving you "PHP can't require '' "errors, check out the bug report i submitted: http://drupal.org/node/914132

Brian