Coded something up in Couch in an interesting way? Have a snippet or shortcode to share? Post it here for the community to benefit.
43 posts Page 4 of 5
Thanks Tim ! It's perfect :)
Hey Tim, I'm having a weird issue with this, was wondering if you can help.
My minify code is (jquery is already loaded)
Code: Select all
<cms:minify 'js' as='js/script.min.js'>
         mode: 'fade',
         moveSlides: 1,
         slideMargin: 0,
         infiniteLoop: true,
            controls: false,
         minSlides: 1,
         maxSlides: 1,
         speed: 800,
            touchEnabled: false,
            auto: true,
            pause: 6000

Everything works as expected, but the problem is in the error log - every time i visit the page I get this error
Code: Select all
PHP Warning:  filemtime(): stat failed for /home/my_site_path/_|*KCODECHUNK*|_ in /home/my_site_path/couch/addons/minify-js-css/minify.php on line 90

I looked, and the function at line 90 is checking the file modification dates, and invalidating the cache etc if necessary. I'm not using timestamps, and if I comment out the function, the error message stops. Other testing narrowed it down to the stuff inbetween the /*CODE*/ blocks - and the error message was generated no matter what I put in there - even a simple alert.

So, it's not a huge issue (as long as it works!), but I don't like errors when I can't fix them :)
Hopefully I'm not missing anything stupid (as is often the case),
Thanks, @ewanmc. I really appreciate the thorough troubleshooting you did.

What's going on there is that the addon doesn't really care if something in the list is a file or not. As you pointed out, it doesn't make any difference to the functioning of the addon, so I never bothered making any checks. Stray characters or comments (in this case the placeholder for your code chunk) just end up being passed over in the natural course of things.

Maybe my error reporting is set to a less strict standard, but I never noticed the warnings being generated. At any rate, I added some checks on whether something in the list is a file or not, so as to avoid throwing the warnings you discovered.

The addon has been updated on the forum and on GitHub.
No worries Tim.
The only reason I noticed it was that I was actively working on a site (trying to improve the SEO ranking), and I noticed the error log kept increasing in size! So I don't really have strict error control standards...
Thanks for your help and a great addition to couch!
Failed to load resource: the server responded with a status of 404 (Not Found)

help me...the output file error...
Sorry for your trouble. Your post doesn't give enough information to help very much with troubleshooting.

First, open the problem page and use the browser to view the source code for the page. Find the line where the CSS or JS file is linked and see if there is a problem with the URL.

Next look at the files on your server and see if the new file has been created.

You may be able to figure out the problem on your own by looking at these two things. Otherwise, please post your cms:minimize code and the HTML code that the page outputs so we can help to solve this problem for you.

I see that this very useful plugin has a fatal problem with PHP Version 7.3.6!
(There is no problem working with version 7.2)
At the end of the generated file is automatically added:

<br />
<b>Deprecated</b>: strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in <b>/home/webroom/domains/couch/couch/addons/minify-js-css/JShrink.php</b> on line <b>210</b><br />

Tim, I ask you to try to fix this because the problem is fatal!
Thank you
Hello all,

@tim taken the liberty of making a modified version of your minify tag.

It accepts an extra file type of 'csscrush', which will use css-crush.php ( to process the css file rather than the built in minify function.

I needed to be able to autoprefix couch generated css and this seemed like a good option.
It has a lot of additional functionailty (mixins, nesting, variables, etc) that I'll be playing with.
A configuration file 'crush_config.php' can be used confgure css-crush.php, see:

@orbital I've also upgraded the JShrink.php to the latest version which should work with PHP 7.3+

I've tested it and all seems to be working. Hope it proves useful.


Hi Tim,

It's about Couch-managed scripts and stylesheets:

Code: Select all
    <cms:minify 'js' as='js/script.min.js'>

The content of couch-managed.php is:
Code: Select all
<cms:content_type 'text/javascript'/>
var maria = "7777";

I see that the cms:minify tag generates a nes js file, but content var maria = "7777" is missing!
Please tell me where I'm wrong?
The file couch-managed.php must be a proper Couch template, with the standard Couch boilerplate and registered by the super-admin.

Did you register it as a Couch template?

If a file doesn't exist or returns an empty string, this add-on simply concatenates nothing into the new file without complaint.

Try opening couch-managed.php directly and see if it is returning the expected content. Also, make sure the filepath is correct.
43 posts Page 4 of 5