Stephen,
Just “found” this awesome extension/plugin and wanted to say thanks. Everything is working fine. However, I wanted to pick your brain 😊
I’m trying to implement Ryan Masuga’s method of dynamically including JS and CSS on the fly in conjunction with your SL Combinator. Ryan’s method uses embeds and passed variables to “call” JS and CSS filenames through a PHP loop. See here. What I can’t figure out is the proper parsing of his embed method and your plugin.
If I wrap your plugin template tags around the PHP loop that determines what files to return in the embed, Minify chokes and mangles the results on the looped filename echo (.$file.).
Scenario 1 Script Embed (some/template)
{embed="global/.scripts" add="jquery.easing"}
Scenario 1 Script Loop (global/.scripts)
{exp:sl_combinator:combine_js disable="no" debug="yes"}
script src="/global/js/jquery.1.3.2.min.js"
{if "{embed:add}" != ""}
<?php $splitcontents = explode('|', '{embed:add}');
foreach($splitcontents as $file) {
echo 'script type="text/javascript" src="/global/js/'.$file.'.js"'."\n";
} ?>
{/if}
{/exp:sl_combinator:combine_js}
Scenario 1 Results
script src="http://www.mysite.com/global/utils/min/index.php?f=global/js/jquery.1.3.2.min.js,global/js/&debug=1">
If I wrap your plugin template tags around the embed tag in the “page” template, not PHP looping script template, they are totally ignored and the embed just spits out individual script tags (like it’s supposed to).
Using Ryan’s method of dynamically including CSS/JS per “page” on an as needed basis and then concatenating, compressing and minifying those files on the fly is like the “Holy Grail” for me. Any light or advice you can shed on the parsing issues will be greatly appreciated. (*angle brackets in script tags removed)
Am I missing something obvious? Thanks for your time in advance.
Eric
HI there.
Hate to add to the list of “it’s not workings”… I’ve had a flick through the past responses and nothing jumps out as being relevant to my situation tho, so here goes.
I’ve got an include (using Solspaces Template Morsels) with the following stuff in it:
<!-- JS -->
{exp:sl_combinator:combine_js disable="no" debug="no"}
[removed][removed]
[removed][removed]
[removed][removed]
<!-- [removed][removed] -->
[removed][removed] <!-- incl tabs and accordian -->
[removed][removed]
<!-- [removed][removed] -->
[removed][removed]
[removed][removed]
[removed][removed]
[removed][removed]
[removed][removed]
[removed][removed] <!-- needed for tooltip -->
[removed][removed] <!-- needed for tooltip -->
[removed][removed] <!-- incl tabs and accordian -->
{/exp:sl_combinator:combine_js}
[removed][removed]
<!-- /JS -->
using the {homepage} to make sure the links are all absolute.
But, it’s basically not putting any JS into the page at all. I’ve done the same with the CSS files and similarly its not making anything.
Something that may be to fault is that I’ve moved the System folder above webroot and masked the CP accordingly. Over the past few days I’ve found a couple other add-ons can’t cope with this, eg Solspaces Related Articles / Tag modules. Could this be causing the problem?
I’ve put the min folder inside {homepage}js/min/ (is inside webroot, unlike the extensions files) and the /min/cache is set to 755. There are no files in there which suggests it’s not getting the right minified files in the right place.
I’m running on a standard domain name (no subdomains / subdirectories. I have the .htaccess file there to remove the index.php file. Its running on a dedicated mini server with cove.com.au. I’m using the latest version of SL combinator with EE 1.6.8 and running on PHP 5.2.11
EDIT: wierd - its stripped out all the JS files from the code above. essentially they all use the “{homepage}js/whatever.filename.js” type of link, so they always remain absolute.
EDIT: wierd - its stripped out all the JS files from the code above. essentially they all use the “{homepage}js/whatever.filename.js” type of link, so they always remain absolute.
OK, the first question is, have you tried just hard-coding the paths? So /js/whatever.filename.js, for example.
If that works, then I suspect it may be a problem with parsing order. If it doesn’t, there’s clearly something else than needs to be addressed first.
Cheers, Stephen
Hi Eric,
If I wrap your plugin template tags around the embed tag in the “page” template, not PHP looping script template, they are totally ignored and the embed just spits out individual script tags (like it’s supposed to).
EE processes embedded templates last, so Combinator isn’t being given any files to work with, hence the individual script tags.
If I wrap your plugin template tags around the embed tag in the “page” template, not PHP looping script template, they are totally ignored and the embed just spits out individual script tags (like it’s supposed to).
Do you have PHP parsing order set to “Input”?
Stephen
P.S. You may find this rather handy.
EDIT: wierd - its stripped out all the JS files from the code above. essentially they all use the “{homepage}js/whatever.filename.js” type of link, so they always remain absolute.OK, the first question is, have you tried just hard-coding the paths? So /js/whatever.filename.js, for example. If that works, then I suspect it may be a problem with parsing order. If it doesn’t, there’s clearly something else than needs to be addressed first. Cheers, Stephen
yeh - i tried all versions - the full absolute address, using the {homapge} global variable, relative paths… none seemed to work. I’ve not changed the [arsing order in any of the templates either.
Just cause it has caused a few problems in the past, moving the system folder above webroot may be the cause - it it can’t place the cached files in an accessible folder, this might be why it’s not working?? Don’t really know, I’m kinda guessing there.
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.
I’ve got the same issue, trying to use the plugin on EE css templates and get a “400 bad request” in return. Are there any updates or workarounds for this yet?
@moogaloo
Can you load the scripts using “manually” using the Minify URL? Something like this should work: http://yoursite.com/utils/min/?f=path/to/file.js,path/to/another/file.js
This is assuming the utils directory is in a publicly-accessible location, which it must be in order for the script to work.
@peternrg / everyone
Are there any updates or workarounds for this yet?
There is no workaround for this at present, and no immediate plans to implement one. Please see my next comment for an explanation of this rather blunt reply.
Cheers, Stephen
Hello everyone,
As I mentioned in a previous comment, this add-on was something that I found useful, and thought others may benefit from, so I released it publicly.
Happily, a lot of people have found it useful. Not so happily, quite a few people have run into problems when using SL Combinator within setups that differ to that for which it was originally written.
My usual approach to this would be the same as for all my other add-ons; resolve any problems, and release an update.
Unfortunately, it’s not quite that simple with SL Combinator, and I would need to put a lot more time into resolving these problems than I have available right now.
I hope this situation will change, but of the foreseeable future this add-on is being provided “as-is”.
Regards, Stephen
P.S. If you happen to encounter a bug or problem that hasn’t been covered in the thread to date, by all means post a message. I’ll do my best to help you resolve it.
no - thats cool - its not a paid for app, so its completely fine to take this line.
That said, the link you gave me does work fine, and using that to link to the one minified stylesheet does work wonders - got 66kb of .css files down to a single 9kb file. Me happy!
Same trick wasn’t working with the JS files. Manually minifying all 12 files or so gave a 400 error, if I strip the list down to only include a couple of ones I knew weren’t already minified / packed/ etc there was no 400 error, but still wasn’t working in a page load as a script.
Happy tho just getting the CSS down to 13% previous size 😊
<
blockquote>Same trick wasn’t working with the JS files. Manually minifying all 12 files or so gave a 400 error, if I strip the list down to only include a couple of ones I knew weren’t already minified / packed/ etc there was no 400 error, but still wasn’t working in a page load as a script.[/quote]
Aha, the penny drops. Minify (for whatever reason) defaults to a maximum of 10 files. This comment provides the details on how to get around this.
Cheers, Stephen
Thanks Stephen for the link to the parse order Wiki page. I’ll play around with the various options (double embed, php parsing stage, etc.)
Edit
Just to follow-up for anyone who may want to use the same technique (Ryan Masuga’s method of dynamically including JS and CSS per template on the fly and SL Combinator) I had to change the template PHP parsing stage to “Input”.
Thanks Stephen for the suggestion. Head slap moment…obviously overlooked. I assumed that Ryan’s method required the template to have parsing set to “output”.
Original post here: http://ellislab.com/forums/viewthread/96429/P72/#691680
Eric
Hi Stephen,
Thanks for taking the time to write this plugin!
I’ve installed it exactly as I’m supposed to, but something is going wrong somewhere. The CSS styles aren’t loading: the output into the html is
<link rel="stylesheet" type="text/css" media="screen" href="/utilities/min/index.php?f=css/master.css,css/lib/reset.css" />
but when clicking that url returns the following error:
Parse error: syntax error, unexpected '=', expecting '(' in /nfs/c05/h04/mnt/55555/domains/domain.com/html/utilities/min/index.php on line 20
I’ve haven’t edited the minify code, but I’ve tried replacing the index.php file with both a new version from your script and the latest version of Minify from Google Code, but with no luck. I’m running PHP5.
Any help greatly appreciated, thanks
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.