Jump to content

AIOM in included file not working


rushy
 Share

Recommended Posts

Just giving AIOM a try and installed it and it works on my JS files but not my CSS files. In my home index page I am using a pattern like this :-

<?php namespace ProcessWire; 
include_once("./_func.php");

if(!$config->ajax){ 
	include("./_init.php");
}
?>

..HTML / Ajax here ...

<?php 
if(!$config->ajax){
	include("./_main.php");
}
?>

and my _init.php has simply the Doctype, <html> opening <head> and my css declarations, closing </head> and opening <body>

my _main.php has my JS includes, closing </body> and </html>

Without AIOM it all works as I expect and validates correctly on W3. But when I add the AIOM to my css in my _init.php as below, I get Class 'ProcessWire\AllInOneMinify' not found.

<link rel="stylesheet" type="text/css" href="<?php echo AllInOneMinify::CSS('css/stylesheet.css'); ?>">

If I remove it from the css files it works fine on the JS files in the _main.php.  I can't understand why it won't work on the css in the head of my project. Any ideas?

Next day: As a test, I moved one of my css links from the _init.php to the _main.php and hey presto it worked! I don't want it in the body part of my project as that's not the correct place for css files is it? I just wonder why when it's included in the head by my _init.php it doesn't know what AllInOneMinify is?

Edited by rushy
Extra info
Link to comment
Share on other sites

Just a guess, but could this be a namespace issue? Have all the files involved got namespace declarations? (Including AIOM?)

Edited by DaveP
Afterthought
  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...