seddass Posted October 8, 2011 Posted October 8, 2011 Hello Ryan, When using $config->styles->... $config->scripts->... in front end templates, there are loaded some stylesheets from admin modules. Will be great if you return back reset() method in FilenameArray.php so prepending $config->styles->reset(); could clean the arrays before loading the frond end styles. I guess you have removed it for some reason. Hope it is not in conflict with other features. Thanks in advance.
ryan Posted October 9, 2011 Posted October 9, 2011 What are you finding in $config->styles on the front end of your site? It should be empty. But I suppose it's possible an autoload module is putting something in there. Just curious what. There hasn't ever been a reset() method in FilenameArray (used by $config->styles/scripts), at least not that I am remembering. I probably wouldn't use that term to clear an array just because the reset() function in PHP means to reset to the beginning rather than to clear. But I will be happy to add such a method to the class. I will call it removeAll() for consistency with other classes in PW. Can you confirm that this is what you need?
seddass Posted October 9, 2011 Author Posted October 9, 2011 ProcessRedirects.css is one of the preloaded css file names (not in home page). I am sure there were a few more in my older sites. Now when you have mentioned.. I have copied the method there on each PW release and in each new site and I am not 100% sure that the method was in FilenameArray before. Seems more likely that I have added it initially. Will be great if you could add removeAll() method to clear the previously loaded values. Thank you!!!
ryan Posted October 10, 2011 Posted October 10, 2011 Okay that makes sense why ProcessRedirects.css would be there–that module is unique in that it's an autoload module, but it's also an admin process. I've added remove() and removeAll() methods to the FilenameArray class, so if you grab the latest commit they should be there. Antti–next time you are making updates to ProcessRedirects, if you want to make it only populate ProcessRedirects.css when it's needed, I would just rename ProcessRedirects.css to something else, and then manually add it to $config->styles at the same time you are creating the output for the page where it is used. This is something I hadn't considered before since Process modules automatically load their related CSS/JS files, but it will be easy for us to get around it.
apeisa Posted October 11, 2011 Posted October 11, 2011 Antti–next time you are making updates to ProcessRedirects, if you want to make it only populate ProcessRedirects.css when it's needed, I would just rename ProcessRedirects.css to something else, and then manually add it to $config->styles at the same time you are creating the output for the page where it is used. This is something I hadn't considered before since Process modules automatically load their related CSS/JS files, but it will be easy for us to get around it. I probably output the required css to html directly. If I remember correctly it is a one liner...
ryan Posted October 11, 2011 Posted October 11, 2011 I probably output the required css to html directly. If I remember correctly it is a one liner... Took a brief look in the code and it doesn't look to me like you are outputting it at all. Any Process module automatically gets any CSS or JS files with the same name included, so it's ProcessWire that's doing it, not ProcessRedirects. ProcessWire does that because it assumes Process modules aren't autoload. It's unusual for a Process module to be autoload, though it makes perfect sense with ProcessRedirects. So the best solution is to just work around it and use a different name for the CSS file (like styles.css) and add it manually, i.e. $config->scripts->add($config->urls->ProcessRedirects . "styles.css"); Not an urgent thing by any means. I will submit a pull if the need comes up here before you get to it. Thanks, Ryan
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now