It looks to me like the problem is that a full URL is being passed to minify, rather than an absolute URL. In other words, if you pass “/css/thingy.css” instead of “http://example.com/css/thingy.css”, it should work.
That’s exactly what I’ve just discovered and so I thought I’d update this thread as I’d read a while back about people having similar issues, but it looks like you beat me to it. I’d been using {site_url}js/script.js and as soon as I took {site_url} out, it worked. 😊
Hi.
Is this not able to be used with stylesheets created through templates?
I’ve tried to implement it as follows.
{exp:sl_combinator:combine_css disable="yes" debug="no"}
<link rel="stylesheet" type="text/css" media="all" href="{stylesheet=styles/layout}" />
<link rel="stylesheet" type="text/css" media="all" href="{stylesheet=styles/navigation}" />
{/exp:sl_combinator:combine_css}
But this returns the following.
<link href="http://mysite.net/scripts/minifier/index.php?f=http://mysite.net/?css=styles/layout.v.1254258090,http://mysite.net/?css=styles/navigation.v.1254257995" media="all" type="text/css" rel="stylesheet">
1HTTP/1.0 400 Bad Request
</link>
I’ve got the same problem as Craig, above - URLs created using {stylesheet=""} (for the versioning) generate full URLs, which don’t work with the plugin. But if you switch to just referencing the template (e.g. href=”styles/navigation”) it generates a 400 Bad Request. This is my generated URL:
http://mysite.com/min/index.php?f=c/main.css,styles/my_theme/
When disabled, the output is as follows:
<link rel="stylesheet" type="text/css" href="/c/main.css">
<link rel="stylesheet" type="text/css" href="/styles/my_theme/">
So it looks like the plugin is creating the correct paths, but something is breaking when it tries to combine and compress a template-generated stylesheet.
Bloody hell Pennell, I’m beginning to wish I’d never met you :|
I’ve got the same problem as Craig, above - URLs created using {stylesheet=”“} (for the versioning) generate full URLs, which don’t work with the plugin. But if you switch to just referencing the template (e.g. href=“styles/navigation”) it generates a 400 Bad Request.
Have you tried using absolute paths when referencing the template directly? If that still causes you problems, I’ll have to do some digging.
Cheers, Stephen
Okay, here are the various things I’ve tried and their rendered HTML/output:
Current, working version, but only minifies the static file
{exp:sl_combinator:combine_css disable="no" debug="no"}
<link rel="stylesheet" type="text/css" href="/c/explorermagazine.css">
{/exp:sl_combinator:combine_css}
<link rel="stylesheet" type="text/css" href="{path="styles/issue_theme"}">
Output is:
<link rel="stylesheet" type="text/css" media="all" href="http://explorermagazine/min/index.php?f=c/explorermagazine.css" />
<link rel="stylesheet" type="text/css" href="http://explorermagazine/styles/issue_theme/">
Now, let’s try just moving that code into the plugin
{exp:sl_combinator:combine_css disable="no" debug="no"}
<link rel="stylesheet" type="text/css" href="/c/explorermagazine.css">
<link rel="stylesheet" type="text/css" href="{path="styles/issue_theme"}">
{/exp:sl_combinator:combine_css}
Output, page is broken (CSS not loaded at all):
<link rel="stylesheet" type="text/css" media="all" href="http://explorermagazine/min/index.php?f=c/explorermagazine.css,{path=" />
Might just need a tweak to a regular expression?
Try it without the domain, just using an absolute path to the template_group/template
{exp:sl_combinator:combine_css disable="no" debug="no"}
<link rel="stylesheet" type="text/css" href="/c/explorermagazine.css">
<link rel="stylesheet" type="text/css" href="/styles/issue_theme/">
{/exp:sl_combinator:combine_css}
Output (CSS not loaded):
<link rel="stylesheet" type="text/css" media="all" href="http://explorermagazine/min/index.php?f=c/explorermagazine.css,styles/issue_theme/" />
Looks like it should be okay, but that URL actually returns a 400 Bad Request.
Thanks for the detailed response Matthew.
I think I’m going to have to take a more in-depth look at the various ways people are using this addon. As is typical with these things, I built something that worked (and continues to work) for me, and released it because I thought others might find it useful too.
Said others then went and did all manner of things I wasn’t expecting.
Anyway, the short answer is that I don’t have a short answer. Sorry for the lack of solution, but I think this requires a bit more work on my part.
Cheers, Stephen
Hi jlee,
Are there plans to make this great plugin MSM compatible? It currently works great on my main EE domain but I get invalid request for site B.
There’s a simple workaround for this:
Cheers, Stephen
Hey Stephen. I am having an issue with the 400 bad request error currently. I am trying to run a css template through the plugin, and it’s coming up with the error. All of the other files I am running through it are working fine, however not this specific stylesheet. My guess is maybe because it’s an EE Template, and not just a flat file.
Here is the line of code that I am using to run it on this file:
{exp:sl_combinator:combine_css disable="no" debug="no"}
<link rel="stylesheet" type="text/css" media="screen" href="{stylesheet=_globals/boilerplate}" />
{/exp:sl_combinator:combine_css}
However it isn’t working. The rendered code looks like this:
<link rel="stylesheet" type="text/css" media="screen" href="http://skinbeautiful.ca/scripts/min/index.php?f=http://skinbeautiful.ca/?css=_globals/boilerplate.v.1259755397" />
however with sl combinator turned on I am getting a 400 bad request when I try to load that generated url.
any help would be greatly appreciated. should I try the basepath setting in the minify script possibly?
Hi Ryan,
All of the other files I am running through it are working fine, however not this specific stylesheet. My guess is maybe because it’s an EE Template, and not just a flat file.
That would be my guess too. It’s a clearly a problem for a number of people, so I need to spend some time looking into this. In other words, I don’t have a quick fix, sorry.
should I try the basepath setting in the minify script possibly?
I don’t think that’s the issue, because you’re not (as far as I’m aware) attempting to serve a file that is outside the server’s DOCUMENT_ROOT. By all means give it a whirl, but I can’t think what you’d need to set it to.
Cheers, Stephen
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.